Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test: "get with reply callback returning default statusCode without body" #1222

Closed
gr2m opened this issue Sep 14, 2018 · 5 comments
Closed
Assignees

Comments

@gr2m
Copy link
Member

gr2m commented Sep 14, 2018

This is a follow up for #1203 (comment). I’ll disable the test for the time being in #1145

@stale
Copy link

stale bot commented Dec 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We try to do our best, but nock is maintained by volunteers and there is only so much we can do at a time. Thank you for your contributions.

@stale stale bot added the stale label Dec 13, 2018
@gr2m gr2m added pinned and removed stale labels Dec 14, 2018
@gr2m gr2m self-assigned this Dec 14, 2018
paulmelnikow added a commit that referenced this issue May 3, 2019
- Add several tests for several missing edge cases.
- Rewrite the test for #1222 so it reflects what I believe is the desired behavior.
- Indicate one test where behavior is supported today but seems unnecessary.
- Add one skipped test for a likely bug.
@paulmelnikow
Copy link
Member

I've been puzzling over this issue in relation to #1203 (comment) and think 🤔I have it sorted out!

In the test run referenced in the linked comment, the failing test was "get with reply callback returning default statusCode without body". It tested that .reply(() => [401]) produced a status code 200 and a body with a JSON-stringified array [401].

This was not the same test as the one added in PR #1203. In that PR the new test was "reply should send correct statusCode with array-notation and without body" and tested that .reply(() => [202]) produced a status code of 202.

It did not make assertions on the body, though the body behavior was unchanged: it sent a JSON-stringified array [202].

It's clear these tests could not have passed at the same time. It's not clear why the PR branch didn't reflect this. (Out of date with master? Flaky test suite? The test suite is more reliable now, in part because of #1465. And also #1077, though that was about fixing false positives rather than false negatives.)

While I agree with #1170, that .reply(() => [201]) should treat 201 as the status code, I disagree with simultaneously interpreting that to mean [201] should be the body. That seems like an unintended effect of that PR.

That behavior is in the process of being changed in #1520, which, if no objections, will cause .reply(() => [201]) to return an empty body.

The documentation is ambiguous, and you could argue this is a bug fix. Though, people may be depending on this have-your-cake-and-eat-it-too behavior that nock has had since 10.0.0, so we may as well label it a breaking change, which will ship (soon! see #1516) as part of v11.

/cc @mastermatt

@paulmelnikow
Copy link
Member

Put another way,

.reply(() => [417])

is currently interpreted as

.reply(() => [417, [417]])

It should instead be interpreted as

.reply(() => [417, ''])

@nockbot
Copy link
Collaborator

nockbot commented May 20, 2019

🎉 This issue has been resolved in version 11.0.0-beta.15 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nockbot
Copy link
Collaborator

nockbot commented Aug 13, 2019

🎉 This issue has been resolved in version 11.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

gr2m pushed a commit that referenced this issue Sep 4, 2019
- Add several tests for several missing edge cases.
- Rewrite the test for #1222 so it reflects what I believe is the desired behavior.
- Indicate one test where behavior is supported today but seems unnecessary.
- Add one skipped test for a likely bug.
gr2m pushed a commit that referenced this issue Sep 4, 2019
- Add several tests for several missing edge cases.
- Rewrite the test for #1222 so it reflects what I believe is the desired behavior.
- Indicate one test where behavior is supported today but seems unnecessary.
- Add one skipped test for a likely bug.
gr2m pushed a commit that referenced this issue Sep 5, 2019
- Add several tests for several missing edge cases.
- Rewrite the test for #1222 so it reflects what I believe is the desired behavior.
- Indicate one test where behavior is supported today but seems unnecessary.
- Add one skipped test for a likely bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants