Nanciee / cypress-autorecord

Simplify API mocking by auto-recording/stubbing HTTP interactions and automating the process of updating/deleting mocks.
223 stars 52 forks source link

Fetch() defaults to 'get' as method (instead of 'GET') #40

Closed marienvo closed 3 years ago

marienvo commented 3 years ago

In our project the browsers fetch() function seems to default the request method to get (instead of uppercase GET); and since the supportedMethods array is all uppercase, this breaks our tests when running with the recorded mocks.

Recording is fine though, but the JSON is incompatible (or lowercase get needs to be added to supportedMethods):

Screenshot from 2021-01-06 11-32-01

This seems to 'fix' the issue: const supportedMethods = ['get', 'GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD'];

Nanciee commented 3 years ago

Thanks for raising this! I'll add in a quick fix this for this. Was this only limited to 'get' or would other request types need to be added as well?

marienvo commented 3 years ago

Thanks! Only the lowercase 'get' gave issues for us, no other request types as far as we've experienced.