Nock.log is silent when headers don't match
See original GitHub issueWhat is the expected behavior? If I use
nock('https://example.com/my_url', { reqheader }).log(console.log);
I would expect that a request to https://example.com would be checked against that route and that the logging would show that.
What is the actual behavior?
Nothing is logged to the console if the headers do not match the specified reqheader This is confusing behaviour and makes people thinks that the nock setups are not being called
Possible solution
Output the attempted match to the console
How to reproduce the issue
Here’s an example, commenting out the reqheader results in the attempted match being logged
Runkit: Example link
Having problem producing a test case? Try and ask the community for help. If the test case cannot be reproduced, the Nock community might not be able to help you.
Does the bug have a test case?
Versions
Software | Version(s) |
---|---|
Nock | 12.0.3 |
Node | v10.17.0 |
TypeScript |
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (7 by maintainers)
Nock does not actually intercept a request unless
reply()
is called after creating an Interceptor with a verb method. Also the correct option name isreqheaders
(plural).This type of question/issue comes up a lot on Github and Stackoverflow. It’s pretty obvious the Readme isn’t sufficient and needs to be updated to cover this nuance. Maybe a second paragraph to READ THIS! - About interceptors
What do we think about this https://github.com/nock/nock/pull/1966 ?
@chrisjensen there can’t be a bug with
.log()
if there is no.log()
. 😉