nock / nock

HTTP server mocking and expectations library for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

got() automatic retries makes for confusing failures in Nock tests

paulmelnikow opened this issue Β· comments

As I mentioned at #1515 (comment), Got automatically retries failed requests twice.

That means if you have a test which mocks a 4xx or 5xx response, got will immediately reissue it.

At that point, the mock will have been consumed. The test will error out with Nock: No match for request.

Adding { retry: 0 } to the got calls will disable this behavior, and will make the tests behave less confusingly.

As I also mentioned in that thread:

While automatic retrying may be nice in certain cases, it is unsuited to testing. I am not convinced it is a good default.

We should use got.extend() to set defaults that turn off this behavior.

πŸŽ‰ This issue has been resolved in version 11.0.0-beta.11 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€

πŸŽ‰ This issue has been resolved in version 11.0.0 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€