Skip to content

Commit

Permalink
Upgrade to Jest 26 (facebook#8955)
Browse files Browse the repository at this point in the history
* Update Jest to 26

* Upgrade to Jest 26.0.1

* Use jest-circus test runner by default

* Try resolving test runner to fix behavior tests

* Run TypeScript verification in new context

* Delete globalThis if polyfilled
  • Loading branch information
ianschmitz authored and jmmorris committed Jun 26, 2020
1 parent ba4fd18 commit 9de9e60
Show file tree
Hide file tree
Showing 11 changed files with 613 additions and 586 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"get-port": "^5.1.1",
"globby": "^11.0.0",
"husky": "^4.2.5",
"jest": "25.5.4",
"jest": "26.0.1",
"lerna": "3.20.2",
"lerna-changelog": "~0.8.2",
"lint-staged": "^10.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-named-asset-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"devDependencies": {
"babel-plugin-tester": "^8.0.1",
"jest": "25.5.4"
"jest": "26.0.1"
},
"scripts": {
"test": "jest"
Expand Down
2 changes: 1 addition & 1 deletion packages/confusing-browser-globals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"index.js"
],
"devDependencies": {
"jest": "25.5.4"
"jest": "26.0.1"
}
}
1,165 changes: 591 additions & 574 deletions packages/create-react-app/yarn.lock.cached

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/react-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
},
"devDependencies": {
"cross-env": "^7.0.2",
"jest": "25.5.4"
"jest": "26.0.1"
},
"scripts": {
"test": "cross-env FORCE_COLOR=true jest"
Expand Down
4 changes: 2 additions & 2 deletions packages/react-error-overlay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@babel/core": "7.10.1",
"anser": "1.4.9",
"babel-eslint": "10.1.0",
"babel-jest": "^25.2.6",
"babel-jest": "^26.0.1",
"babel-loader": "8.1.0",
"babel-preset-react-app": "^9.1.2",
"chalk": "2.4.2",
Expand All @@ -52,7 +52,7 @@
"eslint-plugin-react": "7.20.0",
"flow-bin": "^0.116.0",
"html-entities": "1.3.1",
"jest": "25.5.4",
"jest": "26.0.1",
"jest-fetch-mock": "2.1.2",
"object-assign": "4.1.1",
"promise": "8.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-scripts/fixtures/kitchensink/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"package": {
"dependencies": {
"bootstrap": "4.3.1",
"jest": "25.5.4",
"jest": "26.0.1",
"node-sass": "4.x",
"normalize.css": "7.0.0",
"prop-types": "15.7.2",
Expand Down
9 changes: 5 additions & 4 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@typescript-eslint/eslint-plugin": "^2.10.0",
"@typescript-eslint/parser": "^2.10.0",
"babel-eslint": "10.1.0",
"babel-jest": "^25.2.6",
"babel-jest": "^26.0.1",
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.6",
"babel-preset-react-app": "^9.1.2",
Expand All @@ -56,9 +56,10 @@
"fs-extra": "^9.0.0",
"html-webpack-plugin": "4.3.0",
"identity-obj-proxy": "3.0.0",
"jest": "25.5.4",
"jest-resolve": "25.5.1",
"jest-watch-typeahead": "0.5.0",
"jest": "26.0.1",
"jest-circus": "26.0.1",
"jest-resolve": "26.0.1",
"jest-watch-typeahead": "0.6.0",
"mini-css-extract-plugin": "0.9.0",
"optimize-css-assets-webpack-plugin": "5.0.3",
"pnp-webpack-plugin": "1.6.4",
Expand Down
1 change: 1 addition & 0 deletions packages/react-scripts/scripts/utils/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module.exports = (resolve, rootDir, isEjecting) => {
'<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}',
],
testEnvironment: 'jsdom',
testRunner: require.resolve('jest-circus/runner'),
transform: {
'^.+\\.(js|jsx|mjs|cjs|ts|tsx)$': isEjecting
? '<rootDir>/node_modules/babel-jest'
Expand Down
8 changes: 8 additions & 0 deletions packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,17 @@ function verifyTypeScriptSetup() {
// Ensure typescript is installed
let ts;
try {
// TODO: Remove this hack once `globalThis` issue is resolved
// https://github.com/jsdom/jsdom/issues/2961
const globalThisWasDefined = !!global.globalThis;

ts = require(resolve.sync('typescript', {
basedir: paths.appNodeModules,
}));

if (!globalThisWasDefined && !!global.globalThis) {
delete global.globalThis;
}
} catch (_) {
console.error(
chalk.bold.red(
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/jsconfig/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class App extends Component {
render() {
return (
<div>
{this.state.users.map((user) => (
{this.state.users.map(user => (
<div key={user.id}>{user.name}</div>
))}
</div>
Expand Down

0 comments on commit 9de9e60

Please sign in to comment.