-
-
Notifications
You must be signed in to change notification settings - Fork 734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nock.delete doesn't match request (getting OPTIONS instead of DELETE) #1534
Comments
Hi! It sounds like browsers send an OPTIONS request before a DELETE request: https://stackoverflow.com/a/43485820/893113 So I guess that is what fetch is doing. I just added a test of a DELETE request using got, which did not seem to trigger a second request. If you want to keep using fetch, it looks like you need to add a mock for the OPTIONS request. |
Hi @paulmelnikow, thanks for your response, yes indeed its that behaviour. I added an intercept for OPTIONS method and then the delete and it worked: heres my example working code:
|
Hi, I had the same behaviour with jest on my test, I've added |
I am trying to test a delete request
so in my test I'm doing:
the request is being done correctly but nock is not able to match it as this is what I get in the console
for me this seems to be the same
matching http://localhost:3000/api/auth/logout?token=fakeToken to DELETE http://localhost:3000/api/auth/logout?token=fakeToken: false
I got no issues using request under the other methods (POST, GET) the ones I've tried so far but with DELETE seems to be doing a CORS request so thats why I am getting first the request with the OPTIONS method?
If I change it to use POST for example it works completely fine or get but not DELETE 😔
does anyone has faced the same issue?
I am using "nock": "10.0.6"
The text was updated successfully, but these errors were encountered: