Trying to mock a response on my test (there is no mock server since i only have to mock twice) Im using NightWatch over selenium in reactJS I need to mock a post and a get request. the post request is for a known static URL but the GET one is for a url with a random query inside it like: ?id=example
i managed to mock the post one with NightWatch command .mockNetworkResponse() once, but now its not working for some reason, and the GET one is a bit more complicated since in the url there is a query passed like ?id=example which is random. For some reason the .mockNetworkResponse() is not able to capture it. Ive tired using nock but i cant seem to figure out how to make it work i think its not even performing the nock action when i call for the request
//pre defined command to perform the search that triggers the post request
browser
.searchSpesific('jfk', 'lax',true);
//the command that used to work but now dosn't
browser
.mockNetworkResponse("https://example.com/search",{
status: 200,
headers:{
'Content-Type': 'UTF-8'
},
body: 'intercepted'
})
the GET request URL looks like this: https://example.com/search?id=randomIdString