-
Notifications
You must be signed in to change notification settings - Fork 306
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
Jest 25 #346
Jest 25 #346
Changes from all commits
4794003
7ff98eb
9746992
828a442
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,6 @@ module.exports = { | |
transform: { | ||
'^.+\\.(ts|js|html)$': 'ts-jest', | ||
}, | ||
testEnvironment: 'jest-environment-jsdom-thirteen', | ||
moduleFileExtensions: ['ts', 'html', 'js', 'json'], | ||
moduleNameMapper: { | ||
'^src/(.*)$': '<rootDir>/src/$1', | ||
|
@@ -471,12 +470,16 @@ The same declaration can be applied to other vendor libraries. | |
|
||
Reference: https://github.com/facebook/jest/issues/708 | ||
|
||
### Failing with Node v7 or lower | ||
### Configure other JSDOM versions | ||
|
||
By default we use JSDOM v15, which requires Node v8+. If you want to use Node in a lower version to run your tests, make sure to configure jest to use an older JSDOM version, either in your `jest.config.js`, `jest.config.json` or `package.json`: | ||
**Jest** v25 by default uses **JSDOM** 15 to support Node 8, which should also be compatible with Jest 24 and earlier. | ||
|
||
```json | ||
"testEnvironment": "jsdom" | ||
If you need a newer JSDOM than the one that ships with Jest, install this package using npm install --save-dev jest-environment-jsdom-sixteen or yarn add jest-environment-jsdom-sixteen --dev, and edit your Jest config like so: | ||
|
||
``` | ||
{ | ||
"testEnvironment": "jest-environment-jsdom-sixteen" | ||
} | ||
``` | ||
|
||
If you use JSDOM v11 or lower, you might have to mock `localStorage` or `sessionStorage` on your own or using some third-party library by loading it in `setupFilesAfterEnv`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove paragraphs about JSDOM that are no longer necessary? Jest comes with JSDOM v15 now. If we want to guide users to use newer one, let's update the messaging. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm I think indeed the paragraph is not necessary anymore. What I intended was to provide a fallback user guide but do we need a fallback anymore ? If we don't need, we can just remove the entire paragraph. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the other hand there's jsdom@16 that Jest 25 can't use, because it dropped Node 8. So the small reference can still be helpful to guide users too. But shouldn't be too lengthy There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I propose: Configure other JSDOM versionsIf you want to use another JSDOM version, either in your jest.config.js, jest.config.json or package.json:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's too vague, people will be confused. Let's use concrete example: https://www.npmjs.com/package/jest-environment-jsdom-sixteen There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, referencing the current version seems a good approach here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it has been removed already :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yeah, sorry about that! |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to send a followup :)