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

Jest 25 #346

Merged
merged 4 commits into from
Feb 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
## Changelog (master)

#### Features

* Update `peerDependencies` for `jest` to v25.
* Update `dependencies` for `pretty-format` and `ts-jest` to v25.
* Remove `jest-environment-jsdom-fifteen` from dependencies and preset, closes ([#325](https://github.com/thymikee/jest-preset-angular/issues/325))

#### Chore && Maintenance

* Update project `devDependencies`.
* Update example app dependencies.

### v8.0.0

#### Features
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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:
Copy link
Owner

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 :)

Suggested change
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:
If you need a newer JSDOM than the one that ships with Jest and run Node >=10, you can install `jest-environment-jsdom-sixteen` package, 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`.
Copy link
Owner

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

Copy link
Owner

Choose a reason for hiding this comment

The 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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I propose:

Configure other JSDOM versions

If you want to use another JSDOM version, either in your jest.config.js, jest.config.json or package.json:

"testEnvironment": <jsdom_environment_package>

Copy link
Owner

Choose a reason for hiding this comment

The 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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, referencing the current version seems a good approach here.
Btw, if you could also remove the testEnvironment line from the exposed config in README.md would be awesome!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it has been removed already :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh yeah, sorry about that!

Expand Down
28 changes: 14 additions & 14 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@
},
"private": true,
"dependencies": {
"@angular/animations": "~8.2.5",
"@angular/common": "~8.2.5",
"@angular/compiler": "~8.2.5",
"@angular/core": "~8.2.5",
"@angular/forms": "~8.2.5",
"@angular/platform-browser": "~8.2.5",
"@angular/platform-browser-dynamic": "~8.2.5",
"@angular/router": "~8.2.5",
"@angular/animations": "~8.2.14",
"@angular/common": "~8.2.14",
"@angular/compiler": "~8.2.14",
"@angular/core": "~8.2.14",
"@angular/forms": "~8.2.14",
"@angular/platform-browser": "~8.2.14",
"@angular/platform-browser-dynamic": "~8.2.14",
"@angular/router": "~8.2.14",
"rxjs": "~6.4.0",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.4",
"@angular/cli": "~8.3.4",
"@angular/compiler-cli": "~8.2.5",
"@angular/language-service": "~8.2.5",
"@types/jest": "^24.0.0",
"@angular-devkit/build-angular": "~0.803.25",
"@angular/cli": "~8.3.25",
"@angular/compiler-cli": "~8.2.14",
"@angular/language-service": "~8.2.14",
"@types/jest": "^25.1.1",
"@types/node": "^11.0.0",
"jest": "^24.0.0",
"jest": "^25.1.0",
"jest-preset-angular": "file:../",
"ts-node": "^8.0.3",
"typescript": "~3.5.3"
Expand Down
Loading