diff --git a/package.json b/package.json index 54921946a11..6e6884f2ca2 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "get-port": "^4.2.0", "globby": "^9.1.0", "husky": "^1.3.1", - "jest": "^23.6.0", + "jest": "^24.5.0", "lerna": "2.9.1", "lerna-changelog": "~0.8.2", "lint-staged": "^8.0.4", diff --git a/packages/babel-plugin-named-asset-import/package.json b/packages/babel-plugin-named-asset-import/package.json index 44449f2eeb6..a6c9ccc7c57 100644 --- a/packages/babel-plugin-named-asset-import/package.json +++ b/packages/babel-plugin-named-asset-import/package.json @@ -16,7 +16,7 @@ }, "devDependencies": { "babel-plugin-tester": "^5.5.1", - "jest": "^23.6.0" + "jest": "^24.5.0" }, "scripts": { "test": "jest" diff --git a/packages/confusing-browser-globals/package.json b/packages/confusing-browser-globals/package.json index cb803f3fb44..54edd9c8893 100644 --- a/packages/confusing-browser-globals/package.json +++ b/packages/confusing-browser-globals/package.json @@ -16,6 +16,6 @@ "index.js" ], "devDependencies": { - "jest": "23.6.0" + "jest": "24.5.0" } } diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index cd07fb1dcfb..1c0f172069f 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -74,7 +74,7 @@ }, "devDependencies": { "cross-env": "^5.2.0", - "jest": "^23.6.0" + "jest": "^24.5.0" }, "scripts": { "test": "cross-env FORCE_COLOR=true jest" diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index c855e7909aa..879f3992602 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -35,7 +35,7 @@ "anser": "1.4.8", "babel-core": "7.0.0-bridge.0", "babel-eslint": "10.0.1", - "babel-jest": "23.6.0", + "babel-jest": "24.5.0", "babel-loader": "8.0.5", "babel-preset-react-app": "^7.0.2", "chalk": "^2.4.2", @@ -49,8 +49,8 @@ "eslint-plugin-react": "7.12.4", "flow-bin": "^0.63.1", "html-entities": "1.2.1", - "jest": "23.6.0", - "jest-fetch-mock": "1.6.6", + "jest": "24.5.0", + "jest-fetch-mock": "2.1.1", "object-assign": "4.1.1", "promise": "8.0.2", "raw-loader": "^1.0.0", diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index e45cf8218e1..b892bb90a42 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -1,7 +1,7 @@ { "dependencies": { "bootstrap": "4.1.1", - "jest": "23.6.0", + "jest": "24.5.0", "node-sass": "4.8.3", "normalize.css": "7.0.0", "prop-types": "15.5.6", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index a5aaccf0b3d..7efac8f144f 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -28,7 +28,7 @@ "@svgr/webpack": "4.1.0", "babel-core": "7.0.0-bridge.0", "babel-eslint": "10.0.1", - "babel-jest": "23.6.0", + "babel-jest": "24.5.0", "babel-loader": "8.0.5", "babel-plugin-named-asset-import": "^0.3.1", "babel-preset-react-app": "^7.0.2", @@ -48,9 +48,8 @@ "fs-extra": "7.0.1", "html-webpack-plugin": "4.0.0-beta.5", "identity-obj-proxy": "3.0.0", - "jest": "23.6.0", - "jest-pnp-resolver": "1.0.2", - "jest-resolve": "23.6.0", + "jest": "24.5.0", + "jest-resolve": "24.5.0", "jest-watch-typeahead": "^0.2.1", "mini-css-extract-plugin": "0.5.0", "optimize-css-assets-webpack-plugin": "5.0.1", diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index 5294220b1fe..705f0f87ae3 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -24,20 +24,13 @@ module.exports = (resolve, rootDir, isEjecting) => { const config = { collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!src/**/*.d.ts'], - // TODO: this breaks Yarn PnP on eject. - // But we can't simply emit this because it'll be an absolute path. - // The proper fix is to write jest.config.js on eject instead of a package.json key. - // Then these can always stay as require.resolve()s. - resolver: isEjecting - ? 'jest-pnp-resolver' - : require.resolve('jest-pnp-resolver'), setupFiles: [ isEjecting ? 'react-app-polyfill/jsdom' : require.resolve('react-app-polyfill/jsdom'), ], - setupTestFrameworkScriptFile: setupTestsFile, + setupFilesAfterEnv: setupTestsFile ? [setupTestsFile] : [], testMatch: [ '/src/**/__tests__/**/*.{js,jsx,ts,tsx}', '/src/**/?(*.)(spec|test).{js,jsx,ts,tsx}', @@ -77,6 +70,7 @@ module.exports = (resolve, rootDir, isEjecting) => { 'collectCoverageFrom', 'coverageReporters', 'coverageThreshold', + 'extraGlobals', 'globalSetup', 'globalTeardown', 'resetMocks', @@ -94,13 +88,13 @@ module.exports = (resolve, rootDir, isEjecting) => { const unsupportedKeys = Object.keys(overrides); if (unsupportedKeys.length) { const isOverridingSetupFile = - unsupportedKeys.indexOf('setupTestFrameworkScriptFile') > -1; + unsupportedKeys.indexOf('setupFilesAfterEnv') > -1; if (isOverridingSetupFile) { console.error( chalk.red( 'We detected ' + - chalk.bold('setupTestFrameworkScriptFile') + + chalk.bold('setupFilesAfterEnv') + ' in your package.json.\n\n' + 'Remove it from Jest configuration, and put the initialization code in ' + chalk.bold('src/setupTests.js') + diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index 1be1c18468b..2009ae9a569 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -120,7 +120,7 @@ npx create-react-app --version # ****************************************************************************** cd "$temp_app_path" -npx create-react-app --scripts-version=@latest test-app-dist-tag +npx create-react-app test-app-dist-tag --scripts-version=@latest cd test-app-dist-tag # Check corresponding scripts version is installed and no TypeScript is present. @@ -135,7 +135,7 @@ checkDependencies # ****************************************************************************** cd "$temp_app_path" -npx create-react-app --scripts-version=1.0.17 test-app-version-number +npx create-react-app test-app-version-number --scripts-version=1.0.17 cd test-app-version-number # Check corresponding scripts version is installed. @@ -148,7 +148,7 @@ checkDependencies # ****************************************************************************** cd "$temp_app_path" -npx create-react-app --use-npm --scripts-version=1.0.17 test-use-npm-flag +npx create-react-app test-use-npm-flag --use-npm --scripts-version=1.0.17 cd test-use-npm-flag # Check corresponding scripts version is installed. @@ -196,7 +196,7 @@ CI=true yarn test # ****************************************************************************** cd "$temp_app_path" -npx create-react-app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-1.0.17.tgz test-app-tarball-url +npx create-react-app test-app-tarball-url --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-1.0.17.tgz cd test-app-tarball-url # Check corresponding scripts version is installed. @@ -209,7 +209,7 @@ checkDependencies # ****************************************************************************** cd "$temp_app_path" -npx create-react-app --scripts-version=react-scripts-fork test-app-fork +npx create-react-app test-app-fork --scripts-version=react-scripts-fork cd test-app-fork # Check corresponding scripts version is installed. @@ -221,7 +221,7 @@ exists node_modules/react-scripts-fork cd "$temp_app_path" # we will install a non-existing package to simulate a failed installataion. -npx create-react-app --scripts-version=`date +%s` test-app-should-not-exist || true +npx create-react-app test-app-should-not-exist --scripts-version=`date +%s` || true # confirm that the project files were deleted test ! -e test-app-should-not-exist/package.json test ! -d test-app-should-not-exist/node_modules @@ -234,7 +234,7 @@ cd "$temp_app_path" mkdir test-app-should-remain echo '## Hello' > ./test-app-should-remain/README.md # we will install a non-existing package to simulate a failed installataion. -npx create-react-app --scripts-version=`date +%s` test-app-should-remain || true +npx create-react-app test-app-should-remain --scripts-version=`date +%s` || true # confirm the file exist test -e test-app-should-remain/README.md # confirm only README.md and error log are the only files in the directory @@ -248,7 +248,7 @@ fi cd $temp_app_path curl "https://registry.npmjs.org/@enoah_netzach/react-scripts/-/react-scripts-0.9.0.tgz" -o enoah-scripts-0.9.0.tgz -npx create-react-app --scripts-version=$temp_app_path/enoah-scripts-0.9.0.tgz test-app-scoped-fork-tgz +npx create-react-app test-app-scoped-fork-tgz --scripts-version=$temp_app_path/enoah-scripts-0.9.0.tgz cd test-app-scoped-fork-tgz # Check corresponding scripts version is installed. diff --git a/tasks/e2e-kitchensink-eject.sh b/tasks/e2e-kitchensink-eject.sh index 1640ca85ed4..9cb79e69376 100755 --- a/tasks/e2e-kitchensink-eject.sh +++ b/tasks/e2e-kitchensink-eject.sh @@ -100,7 +100,7 @@ git clean -df # Install the app in a temporary location cd $temp_app_path -npx create-react-app --internal-testing-template="$root_path"/packages/react-scripts/fixtures/kitchensink test-kitchensink +npx create-react-app test-kitchensink --internal-testing-template="$root_path"/packages/react-scripts/fixtures/kitchensink # Install the test module cd "$temp_module_path" diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 2b886a1791a..b57e4550c88 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -100,7 +100,7 @@ git clean -df # Install the app in a temporary location cd $temp_app_path -npx create-react-app --internal-testing-template="$root_path"/packages/react-scripts/fixtures/kitchensink test-kitchensink +npx create-react-app test-kitchensink --internal-testing-template="$root_path"/packages/react-scripts/fixtures/kitchensink # Install the test module cd "$temp_module_path"