-
Notifications
You must be signed in to change notification settings - Fork 310
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
Avoid JSON.stringify hack when testing responses of fetch-mock #588
Comments
I took a look into it. The When using type MockResponse = Response | Promise<Response>
| number | Promise<number>
| string | Promise<string>
| {} | Promise<{}>
| MockResponseObject | Promise<MockResponseObject>; According to this code comment:
This means the Considering these are mocks controlled by ourselves, the alternatives I come up with are: What do you think @octokit/extensibility-sdks @octokit/js-community ? Footnotes |
I think I have a weak preference in favor of
None of those seem deal-breaking to me, though I'd be interested to hear others' thoughts. |
Thumbs up reaction (👍🏽) for |
👍🏼 from me, thank you @oscard0m for taking on this and other chore tasks 💛 |
…ringify in Response assertions More context in #588
There is at least one case where I switched to Those could probably be updated as well |
In a quick search these are the ones I found: The rest can be progressively updated. It's not a problem to have |
#329) <!-- Issues are required for both bug fixes and features. --> Resolves #328 ---- ## Behavior ### Before the change? <!-- Please describe the current behavior that you are modifying. --> Test assertions of Responses from `fetch-mock` are done with `jest.toStrictEqual` with `JSON.stringify` ### After the change? <!-- Please describe the behavior or changes that are being added by this PR. --> Test assertions of Responses from `fetch-mock` are done with `jest.toEqual` ### Other information <!-- Any other information that is important to this PR --> More context in octokit/core.js#588 ---- ## Additional info ### Pull request checklist - [x] Tests for the changes have been added (for bug fixes / features) - [ ] Docs have been reviewed and added / updated if needed (for bug fixes / features) - [ ] Added the appropriate label for the given change ### Does this introduce a breaking change? <!-- If this introduces a breaking change make sure to note it here any what the impact might be --> Please see our docs on [breaking changes](https://github.com/octokit/.github/blob/main/community/breaking_changes.md) to help! - [ ] Yes (Please add the `Type: Breaking change` label) - [x] No If `Yes`, what's the impact: * N/A ### Pull request type `Type: Maintenance` ----
test(refactor): use 'toEqual' instead of 'toMatchObje… more context in octokit/core.js#588
Thank you all for the quick reviews. We are done with this. 🥳 🎆 🍾 |
Affected repos:
toStrictEqual
withJSON.stringify
Response assertions withtoEqual
incore.js
#590toStrictEqual
withJSON.stringify
Response assertions withtoEqual
inrest.js
rest.js#328toStrictEqual
withJSON.stringify
Response assertions withtoEqual
inaction.js
action.js#515toMatchObject
Response assertions withtoEqual
inauth-app.js
auth-app.js#506toMatchObject
Response assertions withtoEqual
inoauth-app.js
oauth-app.js#437Originally posted by @gr2m in #563 (comment)
The text was updated successfully, but these errors were encountered: