fac02d8544
## 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
18 lines
589 B
JavaScript
18 lines
589 B
JavaScript
module.exports = {
|
|
roots: ['<rootDir>'],
|
|
testEnvironment: 'jsdom',
|
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'jsx'],
|
|
testPathIgnorePatterns: ['<rootDir>[/\\\\](node_modules|.next)[/\\\\]'],
|
|
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(ts|tsx)$'],
|
|
transform: {
|
|
'^.+\\.(ts|tsx)$': 'babel-jest',
|
|
},
|
|
watchPlugins: [
|
|
'jest-watch-typeahead/filename',
|
|
'jest-watch-typeahead/testname',
|
|
],
|
|
moduleNameMapper: {
|
|
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
|
|
'\\.(gif|ttf|eot|svg|png)$': '<rootDir>/test/__mocks__/fileMock.js',
|
|
},
|
|
}
|