Skip to content

Commit

Permalink
Follow the breaking change of jest-config (#26082)
Browse files Browse the repository at this point in the history
## Documentation / Examples

When I create a new application using Next.js and use `jest` or `react-testing-library`, I get the following error.
```
The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/configuration#testenvironment-string.
    Consider using the "jsdom" test environment.
    
    ReferenceError: document is not defined
```
This is because `jest-config` changed the default testing environment to node in 27.0.
> `jest-config@27.0.0` default to Node testing environment instead of browser (JSDOM) (#9874)


Raised the jest version of `with-typescript-eslint-jest` to 27.0 to make it pass the test.

- [x] Make sure the linting passes
  • Loading branch information
toyamarinyon authored Jun 16, 2021
1 parent 722d08e commit fac02d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions examples/with-typescript-eslint-jest/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
roots: ['<rootDir>'],
testEnvironment: 'jsdom',
moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'jsx'],
testPathIgnorePatterns: ['<rootDir>[/\\\\](node_modules|.next)[/\\\\]'],
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(ts|tsx)$'],
Expand Down
6 changes: 3 additions & 3 deletions examples/with-typescript-eslint-jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@
},
"devDependencies": {
"@testing-library/react": "^11.2.5",
"@types/jest": "^26.0.20",
"@types/jest": "^26.0.23",
"@types/node": "^14.14.25",
"@types/react": "^17.0.1",
"@typescript-eslint/eslint-plugin": "^4.14.2",
"@typescript-eslint/parser": "^4.14.2",
"babel-jest": "^26.6.3",
"babel-jest": "^27.0.2",
"eslint": "^7.19.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-react": "^7.19.0",
"husky": "^4.2.3",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.6.3",
"jest": "^27.0.4",
"jest-watch-typeahead": "^0.6.1",
"lint-staged": "^10.0.10",
"prettier": "^2.0.2",
Expand Down

0 comments on commit fac02d8

Please sign in to comment.