Skip to content

fix(recorder): allow recording req headers when not outputting objects#1617

Merged
mastermatt merged 2 commits intonock:betafrom
mastermatt:recorder-coverage
Jul 15, 2019
Merged

fix(recorder): allow recording req headers when not outputting objects#1617
mastermatt merged 2 commits intonock:betafrom
mastermatt:recorder-coverage

Conversation

@mastermatt
Copy link
Copy Markdown
Member

Fixes #1607 (assuming #1616 is merged in first)
Part of #1404

While this work started out as just an effort to add coverage to recorder.js, I found/fixed a bug so I'm using the fix type.

There was a bug that kept request headers from being added to matchHeader lines in non-object outputs.
enable_reqheaders_recording was only having an affect if output_objects was also true, but headers were never being added despite that because it was looking for headers under the wrong attribute on the request.
A test was added to cover the flow of wanting the matchHeader as the other flow was already covered.

There are a couple other changes intertwined with the bug fix. It seemed cleaner to PR them together since it's all so tightly coupled. Things to keep in mind:

There was no test that `output_objects: true`, without also setting
`dont_print: true` so this flow was not covered.
When exploring coverage gaps a few things were uncovered:
- OutgoingMessage._headers has been deprecated in favor of `getHeaders()`. https://nodejs.org/api/deprecations.html#deprecations_dep0066_outgoingmessage_prototype_headers_outgoingmessage_prototype_headernames
- IncommingMessage.rawHeaders is never falsy so there isn't a need to fall back to `headers`
- There was a bug that kept request headers from being added to `matchHeader` lines in non-object outputs.
  `enable_reqheaders_recording` was only having an affect if `output_objects` was also true, but headers were never being added despite that because it was looking for headers under the wrong attribute on the request.
  A test was added to cover the flow of wanting the `matchHeader` as the other flow was already covered.
@mastermatt mastermatt added the bug label Jul 12, 2019
@mastermatt mastermatt requested review from gr2m and paulmelnikow July 12, 2019 04:41
Copy link
Copy Markdown
Member

@gr2m gr2m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Nice catch, too 👍

@mastermatt mastermatt merged commit a952d9b into nock:beta Jul 15, 2019
@mastermatt mastermatt deleted the recorder-coverage branch July 15, 2019 01:40
@nockbot
Copy link
Copy Markdown
Collaborator

nockbot commented Jul 15, 2019

🎉 This PR is included in version 11.0.0-beta.24 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nockbot
Copy link
Copy Markdown
Collaborator

nockbot commented Aug 12, 2019

🎉 This PR is included in version 11.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

gr2m pushed a commit that referenced this pull request Sep 4, 2019
#1617)

* test: add coverage for logging recorded objects

There was no test that `output_objects: true`, without also setting
`dont_print: true` so this flow was not covered.

* fix: allow recording req headers when not outputting objects

When exploring coverage gaps a few things were uncovered:
- OutgoingMessage._headers has been deprecated in favor of `getHeaders()`. https://nodejs.org/api/deprecations.html#deprecations_dep0066_outgoingmessage_prototype_headers_outgoingmessage_prototype_headernames
- IncommingMessage.rawHeaders is never falsy so there isn't a need to fall back to `headers`
- There was a bug that kept request headers from being added to `matchHeader` lines in non-object outputs.
  `enable_reqheaders_recording` was only having an affect if `output_objects` was also true, but headers were never being added despite that because it was looking for headers under the wrong attribute on the request.
  A test was added to cover the flow of wanting the `matchHeader` as the other flow was already covered.
gr2m pushed a commit that referenced this pull request Sep 4, 2019
#1617)

* test: add coverage for logging recorded objects

There was no test that `output_objects: true`, without also setting
`dont_print: true` so this flow was not covered.

* fix: allow recording req headers when not outputting objects

When exploring coverage gaps a few things were uncovered:
- OutgoingMessage._headers has been deprecated in favor of `getHeaders()`. https://nodejs.org/api/deprecations.html#deprecations_dep0066_outgoingmessage_prototype_headers_outgoingmessage_prototype_headernames
- IncommingMessage.rawHeaders is never falsy so there isn't a need to fall back to `headers`
- There was a bug that kept request headers from being added to `matchHeader` lines in non-object outputs.
  `enable_reqheaders_recording` was only having an affect if `output_objects` was also true, but headers were never being added despite that because it was looking for headers under the wrong attribute on the request.
  A test was added to cover the flow of wanting the `matchHeader` as the other flow was already covered.
gr2m pushed a commit that referenced this pull request Sep 5, 2019
#1617)

* test: add coverage for logging recorded objects

There was no test that `output_objects: true`, without also setting
`dont_print: true` so this flow was not covered.

* fix: allow recording req headers when not outputting objects

When exploring coverage gaps a few things were uncovered:
- OutgoingMessage._headers has been deprecated in favor of `getHeaders()`. https://nodejs.org/api/deprecations.html#deprecations_dep0066_outgoingmessage_prototype_headers_outgoingmessage_prototype_headernames
- IncommingMessage.rawHeaders is never falsy so there isn't a need to fall back to `headers`
- There was a bug that kept request headers from being added to `matchHeader` lines in non-object outputs.
  `enable_reqheaders_recording` was only having an affect if `output_objects` was also true, but headers were never being added despite that because it was looking for headers under the wrong attribute on the request.
  A test was added to cover the flow of wanting the `matchHeader` as the other flow was already covered.
juninmd pushed a commit to juninmd/nock that referenced this pull request Mar 21, 2026
nock#1617)

* test: add coverage for logging recorded objects

There was no test that `output_objects: true`, without also setting
`dont_print: true` so this flow was not covered.

* fix: allow recording req headers when not outputting objects

When exploring coverage gaps a few things were uncovered:
- OutgoingMessage._headers has been deprecated in favor of `getHeaders()`. https://nodejs.org/api/deprecations.html#deprecations_dep0066_outgoingmessage_prototype_headers_outgoingmessage_prototype_headernames
- IncommingMessage.rawHeaders is never falsy so there isn't a need to fall back to `headers`
- There was a bug that kept request headers from being added to `matchHeader` lines in non-object outputs.
  `enable_reqheaders_recording` was only having an affect if `output_objects` was also true, but headers were never being added despite that because it was looking for headers under the wrong attribute on the request.
  A test was added to cover the flow of wanting the `matchHeader` as the other flow was already covered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants