-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1622: Update Jest r=curquiza a=flevi29 # Pull Request ## Related issue Fixes #1621 ## What does this PR do? - because newer versions of jest doesn't include anymore "jest-environment-jsdom", add it as development dependency - because newer versions of jest simplified snapshots, update them accordingly - this means replacing `Object {` with `{` and `Array [` with `[` - because newer versions of jest support builtin `fetch` from newer versions of Node.js, add a global setup script that disables builtin `fetch` - this is because builtin `fetch` breaks a lot of tests, regarding errors, abort, and even objects created by `fetch` are different, for instance some arrays no longer return `true` for `expect.any(Array)` (something to do with `instanceof Array`) (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray#description) - `jasmine` `fail()` doesn't work anymore, but it still fails the tests, except with a less convenient error message `ReferenceError: fail is not defined` https://jestjs.io/blog/2021/05/25/jest-27#flipping-defaults EDIT: just realized it says here that we can set `"testRunner": "jest-jasmine2"`, but I tried it and `fail()` is still undefined - should fix this in a separate PR, where we fix/improve the tests, this PR is about updating Jest and making minimal code changes for it to work ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: F. Levi <55688616+flevi29@users.noreply.github.com>
- Loading branch information
Showing
10 changed files
with
1,783 additions
and
2,252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ examples | |
scripts | ||
tests/env | ||
coverage | ||
/jest-disable-built-in-fetch.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = function () { | ||
// This is required for tests to work with "cross-fetch" on newer node versions, | ||
// otherwise "cross-fetch" won't replace the builtin `fetch` | ||
globalThis.fetch = undefined | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.