You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
matchHeader no longer functions as expected, neither when providing value as a string or a function. The culprit seems to be options.getHeader returning undefined for every header name because request._headers (v9.0.13) is not set anymore.
I'm seeing this issue as well. It looks like this is a result of nodejs/node#10941 (nodejs/node@b377034359a specifically) which made the ._headers property of OutgoingMessage return a copy of the headers object. This copy is assigned to in setHeaders, which has no lasting effect.
Is there a reason why request.setHeader (OutgoingMessage.prototype.setHeader) isn't being called here?
Replacing the matchHeader function with nock(host, { reqheaders: {"header":"content"} }), seems to do the trick for now.
I'm using Nock 9.0.13 and Node 8 (on Official Docker Image)
@dickeyxxx doesn't look like it does, I don't mock all my headers and the tests are working just fine with the mentioned change.
Also the header assertions are working as expected (tests will fail if the supplied header content doesn't match the expectation).
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!
Activity
kevinoid commentedon May 31, 2017
I'm seeing this issue as well. It looks like this is a result of nodejs/node#10941 (nodejs/node@b377034359a specifically) which made the
._headersproperty ofOutgoingMessagereturn a copy of the headers object. This copy is assigned to insetHeaders, which has no lasting effect.Is there a reason why
request.setHeader(OutgoingMessage.prototype.setHeader) isn't being called here?skip test using nock.matchHeader in node 8 for now
Fix for nock#925
skip test using nock method broken in node 8
jhuliano commentedon Jun 7, 2017
Replacing the
matchHeaderfunction withnock(host, { reqheaders: {"header":"content"} }), seems to do the trick for now.I'm using Nock 9.0.13 and Node 8 (on Official Docker Image)
jdx commentedon Jun 7, 2017
that requires you to specify all the headers though, right?
jhuliano commentedon Jun 7, 2017
@dickeyxxx doesn't look like it does, I don't mock all my headers and the tests are working just fine with the mentioned change.
Also the header assertions are working as expected (tests will fail if the supplied header content doesn't match the expectation).
jdx commentedon Jun 7, 2017
good to know! thank you!
acofer commentedon Jun 8, 2017
#930
Workaround for nock bug in nodejs 8
Update test matrix, post Node 8
Apply patch to nock
shahata commentedon Jul 8, 2017
any plans of fixing this soon?
Workaround for nock bug in nodejs 8
0xcaff commentedon Jul 14, 2017
It looks like this is fixed in the latest commit to master: 35c76e3
ianwsperber commentedon Jul 14, 2017
Will be released end of weekend
ianwsperber commentedon Jul 17, 2017
v9.0.14 out with @martinkuba's fix. Huge thanks to him for doing the work. Closing this issue. Will re-open if we get reports that issue persists.
panva commentedon Jul 17, 2017
resolved, @ianwsperber @martinkuba thanks!
Workaround for nock bug in nodejs 8
Require nock ^9.0.14
lock commentedon Sep 13, 2018
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!