Mock relative (root) URL
See original GitHub issueI’m trying to mock calls to /users
, so requests are going to the root. When I try to do:
nock('').get('/users');
I get TypeError: Cannot read property 'replace' of null
.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:7
Top Results From Across the Web
Relative URL as hostname in Nock - Stack Overflow
I'm using isomorphic-fetch in the client side and I'm using mocha and nock for testing and mocking. All my client requests are based...
Read more >Mock Service Worker - Using Base URL - YouTube
Using Base URL — Mocking REST API with Mock Service Worker ... like "gitHubApi" to resolve relative paths to absolute service URLs.
Read more >How to specify the base URL for all relative URLs in a ...
In the below code, we have set “https://www.geeksforgeeks.org/” as the root URL for every relative URL on the page.
Read more >Request matching - Basics - Mock Service Worker Docs
Note that relative URL are resolved against the current location ( location.origin ). Path. Mock Service Worker uses an Express-like path syntax ...
Read more >Manual Mocks - Jest
If the module you are mocking is a Node module (e.g.: lodash ), the mock should be placed in the __mocks__ directory adjacent...
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 Free
Top 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
I ran into this exact problem and solved it by using the
fetch-mock
library instead ofnock
:https://github.com/wheresrhys/fetch-mock/
short answer, you can’t… you have to have a http://something, you could call localhost, you could call the final API url, but you have to have a url 😦 struggled on that a few weeks ago to test some async actions with redux and redux-thunk