reqheaders does not work when using an undefined requestBody
josephearl opened this issue · comments
Please avoid duplicates
- I checked all open bugs and none of them matched my problem.
Reproducible test case
https://github.com/josephearl/nock-reqheaders-repro
Nock Version
13.3.7
Node Version
v18.17.1
TypeScript Version
N/A
What happened?
When creating a request matcher and using reqheaders
, these do not work when setting an undefined requestBody
:
mock.get('/some/path', undefined, {
reqheaders: { 'HEADER1': 'value1', 'HEADER2': 'value1' }
}).reply(200);
Strangely if you use null
for the requestBody
it does work - but null
is not allowed by the TypeScript types which specificy requestBody
must be undefined | RequestBody
and the RequestBody
type does not include null
in its union.
Expected is that when using undefined
for a requestBody
the reqheaders
matching still works.
See https://github.com/josephearl/nock-reqheaders-repro/tree/main for a reproducer.
NB: the all open bugs
link (https://github.com/nock/nock.js/issues?q=is%3Aissue+is%3Aopen+label%3Abug) in your issue template leads to a 404 - because it is pointing to an old repo name nock.js
Would you be interested in contributing a fix?
- yes
NB: the
all open bugs
link (https://github.com/nock/nock.js/issues?q=is%3Aissue+is%3Aopen+label%3Abug) in your issue template leads to a 404 - because it is pointing to an old repo namenock.js
thanks, fixed 👍