When specifying the endpoint, not matching any mocked endpoint
See original GitHub issueEnvironment
Name | Version |
---|---|
msw | 0.19.5 |
node | 12.18.1 |
OS | Windows 10 Pro |
Request handlers
import { rest } from 'msw';
import { setupServer } from 'msw/node';
//Also tried http://localhost:*, http://localhost:5000/todo*, http://localhost:*/todo*
const handlers = [
rest.get('/todo', (req, res, ctx) => {
return Promise.resolve(res(ctx.json({
currentPage: 1,
pageSize: 1,
pageCount: 1,
totalRowCount: 0,
result: [],
})));
})]
const server = setupServer(...handlers);
beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
afterAll(() => server.close());
Actual request
// Example of making a request. Provide your code here.
fetch("http://localhost:5000/api/todo").then(result => {
console.log('LOOK AT ME', result);
return result;
});
Current behavior
The request URL is coming in empty. Also, the request not mapping to the correct path, only works when I use wildcard “*”.
Expected behavior
Intercepting the call and routing to the correct mocked endpoint.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to allow non mocked endpoints when using responses ...
E.g. Actually access the 'http://google.com' endpoint to run the function, then mock other data from another endpoint and test my function.
Read more >Request matching - Basics - Mock Service Worker Docs
Requests with no corresponding request handlers are performed as-is (bypassed ). Request matching substantially differs based on the request ...
Read more >Understanding example matching | Postman Learning Center
Using Postman's mock servers requires a collection with requests and saved request examples. You can save as many examples to a collection ...
Read more >AdviceWith - Apache Camel
Mocks all endpoints in the route that matches the patterns. You can use wildcards and regular expressions in the given pattern to match...
Read more >Returning stubbed HTTP responses to specific requests
A core feature of WireMock API mocking is the ability to return canned ... You can specify ANY if you want the stub...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Even with jsdom, msw doesn’t match requests unless the absolute URL is specified. Seems like a bug, either in the implementation or the docs.
I see, thank you!