From 149383e2582d0316f5d0fc6af17abc88e253b6b0 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 19 Sep 2023 13:16:01 +0200 Subject: [PATCH 1/4] fix(pretty-format): Handle empty string children in React same as `react-test-renderer` (#14470) --- CHANGELOG.md | 1 + constraints.pro | 4 - e2e/babel-plugin-jest-hoist/package.json | 2 +- e2e/babel-plugin-jest-hoist/yarn.lock | 18 +--- .../multiple-transformers/package.json | 6 +- e2e/transform/multiple-transformers/yarn.lock | 65 ++++++------- examples/react-testing-library/package.json | 2 +- examples/react/package.json | 2 +- examples/snapshot/package.json | 4 +- examples/typescript/package.json | 2 +- packages/pretty-format/package.json | 10 +- .../src/__tests__/react.test.tsx | 5 +- .../pretty-format/src/plugins/ReactElement.ts | 2 +- website/package.json | 6 +- yarn.lock | 91 +++++-------------- 15 files changed, 74 insertions(+), 146 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc8e232edbb2..9ccbbcf83e95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - `[jest-environment-jsdom]` [**BREAKING**] Upgrade JSDOM to v22 ([#13825](https://github.com/jestjs/jest/pull/13825)) - `[@jest/test-sequencer, jest-core]` [**BREAKING**] Exposes `globalConfig` & `contexts` to `TestSequencer` ([#14535](https://github.com/jestjs/jest/pull/14535), & [#14543](https://github.com/jestjs/jest/pull/14543)) +- `[pretty-format]` [**BREAKING**] Do not render empty string children (`''`) in React plugin ([#14470](https://github.com/facebook/jest/pull/14470)) ### Fixes diff --git a/constraints.pro b/constraints.pro index eb59863a1c6c..62235e22de6b 100644 --- a/constraints.pro +++ b/constraints.pro @@ -19,10 +19,6 @@ gen_enforced_dependency(WorkspaceCwd, DependencyIdent, DependencyRange2, Depende DependencyType2 \= 'peerDependencies', % A list of exception to same version rule \+ member(DependencyIdent, [ - % Allow enzyme example workspace use a older version react and react-dom, because enzyme don't support react 17 - 'react', 'react-dom', '@types/react', - % Only RN should be bumped to react 18 - 'react-test-renderer', % @types/node in the root need to stay on ~14.14.45 '@types/node', % upgrading the entire repository is a breaking change diff --git a/e2e/babel-plugin-jest-hoist/package.json b/e2e/babel-plugin-jest-hoist/package.json index b55189deec84..5212c713b125 100644 --- a/e2e/babel-plugin-jest-hoist/package.json +++ b/e2e/babel-plugin-jest-hoist/package.json @@ -3,7 +3,7 @@ "@babel/preset-env": "^7.0.0", "@babel/preset-flow": "^7.0.0", "@babel/preset-typescript": "^7.0.0", - "react": "17.0.2" + "react": "18.2.0" }, "jest": { "automock": true, diff --git a/e2e/babel-plugin-jest-hoist/yarn.lock b/e2e/babel-plugin-jest-hoist/yarn.lock index f19b97c69d42..13a49935ba37 100644 --- a/e2e/babel-plugin-jest-hoist/yarn.lock +++ b/e2e/babel-plugin-jest-hoist/yarn.lock @@ -1573,13 +1573,6 @@ __metadata: languageName: node linkType: hard -"object-assign@npm:^4.1.1": - version: 4.1.1 - resolution: "object-assign@npm:4.1.1" - checksum: fcc6e4ea8c7fe48abfbb552578b1c53e0d194086e2e6bbbf59e0a536381a292f39943c6e9628af05b5528aa5e3318bb30d6b2e53cadaf5b8fe9e12c4b69af23f - languageName: node - linkType: hard - "path-parse@npm:^1.0.7": version: 1.0.7 resolution: "path-parse@npm:1.0.7" @@ -1594,13 +1587,12 @@ __metadata: languageName: node linkType: hard -"react@npm:17.0.2": - version: 17.0.2 - resolution: "react@npm:17.0.2" +"react@npm:18.2.0": + version: 18.2.0 + resolution: "react@npm:18.2.0" dependencies: loose-envify: ^1.1.0 - object-assign: ^4.1.1 - checksum: b254cc17ce3011788330f7bbf383ab653c6848902d7936a87b09d835d091e3f295f7e9dd1597c6daac5dc80f90e778c8230218ba8ad599f74adcc11e33b9d61b + checksum: 88e38092da8839b830cda6feef2e8505dec8ace60579e46aa5490fc3dc9bba0bd50336507dc166f43e3afc1c42939c09fe33b25fae889d6f402721dcd78fca1b languageName: node linkType: hard @@ -1694,7 +1686,7 @@ __metadata: "@babel/preset-env": ^7.0.0 "@babel/preset-flow": ^7.0.0 "@babel/preset-typescript": ^7.0.0 - react: 17.0.2 + react: 18.2.0 languageName: unknown linkType: soft diff --git a/e2e/transform/multiple-transformers/package.json b/e2e/transform/multiple-transformers/package.json index f0f60dd9cba5..889c6879050a 100644 --- a/e2e/transform/multiple-transformers/package.json +++ b/e2e/transform/multiple-transformers/package.json @@ -17,8 +17,8 @@ "@babel/core": "^7.0.0", "@babel/preset-env": "^7.0.0", "@babel/preset-react": "^7.0.0", - "react": "17.0.2", - "react-dom": "^17.0.1", - "react-test-renderer": "17.0.2" + "react": "18.2.0", + "react-dom": "18.2.0", + "react-test-renderer": "18.2.0" } } diff --git a/e2e/transform/multiple-transformers/yarn.lock b/e2e/transform/multiple-transformers/yarn.lock index 193ae9527214..25fc57bd97a5 100644 --- a/e2e/transform/multiple-transformers/yarn.lock +++ b/e2e/transform/multiple-transformers/yarn.lock @@ -1738,34 +1738,26 @@ __metadata: languageName: node linkType: hard -"react-dom@npm:^17.0.1": - version: 17.0.2 - resolution: "react-dom@npm:17.0.2" +"react-dom@npm:18.2.0": + version: 18.2.0 + resolution: "react-dom@npm:18.2.0" dependencies: loose-envify: ^1.1.0 - object-assign: ^4.1.1 - scheduler: ^0.20.2 + scheduler: ^0.23.0 peerDependencies: - react: 17.0.2 - checksum: 1c1eaa3bca7c7228d24b70932e3d7c99e70d1d04e13bb0843bbf321582bc25d7961d6b8a6978a58a598af2af496d1cedcfb1bf65f6b0960a0a8161cb8dab743c + react: ^18.2.0 + checksum: 7d323310bea3a91be2965f9468d552f201b1c27891e45ddc2d6b8f717680c95a75ae0bc1e3f5cf41472446a2589a75aed4483aee8169287909fcd59ad149e8cc languageName: node linkType: hard -"react-is@npm:^16.12.0 || ^17.0.0 || ^18.0.0": +"react-is@npm:^16.12.0 || ^17.0.0 || ^18.0.0, react-is@npm:^18.2.0": version: 18.2.0 resolution: "react-is@npm:18.2.0" checksum: e72d0ba81b5922759e4aff17e0252bd29988f9642ed817f56b25a3e217e13eea8a7f2322af99a06edb779da12d5d636e9fda473d620df9a3da0df2a74141d53e languageName: node linkType: hard -"react-is@npm:^17.0.2": - version: 17.0.2 - resolution: "react-is@npm:17.0.2" - checksum: 9d6d111d8990dc98bc5402c1266a808b0459b5d54830bbea24c12d908b536df7883f268a7868cfaedde3dd9d4e0d574db456f84d2e6df9c4526f99bb4b5344d8 - languageName: node - linkType: hard - -"react-shallow-renderer@npm:^16.13.1": +"react-shallow-renderer@npm:^16.15.0": version: 16.15.0 resolution: "react-shallow-renderer@npm:16.15.0" dependencies: @@ -1777,27 +1769,25 @@ __metadata: languageName: node linkType: hard -"react-test-renderer@npm:17.0.2": - version: 17.0.2 - resolution: "react-test-renderer@npm:17.0.2" +"react-test-renderer@npm:18.2.0": + version: 18.2.0 + resolution: "react-test-renderer@npm:18.2.0" dependencies: - object-assign: ^4.1.1 - react-is: ^17.0.2 - react-shallow-renderer: ^16.13.1 - scheduler: ^0.20.2 + react-is: ^18.2.0 + react-shallow-renderer: ^16.15.0 + scheduler: ^0.23.0 peerDependencies: - react: 17.0.2 - checksum: e6b5c6ed2a0bde2c34f1ab9523ff9bc4c141a271daf730d6b852374e83acc0155d58ab71a318251e953ebfa65b8bebb9c5dce3eba1ccfcbef7cc4e1e8261c401 + react: ^18.2.0 + checksum: 6b6980ced93fa2b72662d5e4ab3b4896833586940047ce52ca9aca801e5432adf05fcbe28289b0af3ce6a2a7c590974e25dcc8aa43d0de658bfe8bbcd686f958 languageName: node linkType: hard -"react@npm:17.0.2": - version: 17.0.2 - resolution: "react@npm:17.0.2" +"react@npm:18.2.0": + version: 18.2.0 + resolution: "react@npm:18.2.0" dependencies: loose-envify: ^1.1.0 - object-assign: ^4.1.1 - checksum: b254cc17ce3011788330f7bbf383ab653c6848902d7936a87b09d835d091e3f295f7e9dd1597c6daac5dc80f90e778c8230218ba8ad599f74adcc11e33b9d61b + checksum: 88e38092da8839b830cda6feef2e8505dec8ace60579e46aa5490fc3dc9bba0bd50336507dc166f43e3afc1c42939c09fe33b25fae889d6f402721dcd78fca1b languageName: node linkType: hard @@ -1891,19 +1881,18 @@ __metadata: "@babel/core": ^7.0.0 "@babel/preset-env": ^7.0.0 "@babel/preset-react": ^7.0.0 - react: 17.0.2 - react-dom: ^17.0.1 - react-test-renderer: 17.0.2 + react: 18.2.0 + react-dom: 18.2.0 + react-test-renderer: 18.2.0 languageName: unknown linkType: soft -"scheduler@npm:^0.20.2": - version: 0.20.2 - resolution: "scheduler@npm:0.20.2" +"scheduler@npm:^0.23.0": + version: 0.23.0 + resolution: "scheduler@npm:0.23.0" dependencies: loose-envify: ^1.1.0 - object-assign: ^4.1.1 - checksum: c4b35cf967c8f0d3e65753252d0f260271f81a81e427241295c5a7b783abf4ea9e905f22f815ab66676f5313be0a25f47be582254db8f9241b259213e999b8fc + checksum: d79192eeaa12abef860c195ea45d37cbf2bbf5f66e3c4dcd16f54a7da53b17788a70d109ee3d3dde1a0fd50e6a8fc171f4300356c5aee4fc0171de526bf35f8a languageName: node linkType: hard diff --git a/examples/react-testing-library/package.json b/examples/react-testing-library/package.json index cdbddd0c7582..7d8696af0665 100644 --- a/examples/react-testing-library/package.json +++ b/examples/react-testing-library/package.json @@ -4,7 +4,7 @@ "name": "example-react-testing-library", "dependencies": { "react": "18.2.0", - "react-dom": "^18.2.0" + "react-dom": "18.2.0" }, "devDependencies": { "@babel/core": "^7.11.6", diff --git a/examples/react/package.json b/examples/react/package.json index 1d9d615fcb0f..ac36194fba3d 100644 --- a/examples/react/package.json +++ b/examples/react/package.json @@ -4,7 +4,7 @@ "name": "example-react", "dependencies": { "react": "18.2.0", - "react-dom": "^18.2.0" + "react-dom": "18.2.0" }, "devDependencies": { "@babel/core": "^7.11.6", diff --git a/examples/snapshot/package.json b/examples/snapshot/package.json index 2080a7f59882..914ea02b65d3 100644 --- a/examples/snapshot/package.json +++ b/examples/snapshot/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "name": "example-snapshot", "dependencies": { - "react": "17.0.2" + "react": "18.2.0" }, "devDependencies": { "@babel/core": "^7.11.6", @@ -11,7 +11,7 @@ "@babel/preset-react": "^7.12.1", "babel-jest": "workspace:^", "jest": "workspace:^", - "react-test-renderer": "17.0.2" + "react-test-renderer": "18.2.0" }, "scripts": { "test": "jest" diff --git a/examples/typescript/package.json b/examples/typescript/package.json index c1d873ee9ed9..6188712899b3 100644 --- a/examples/typescript/package.json +++ b/examples/typescript/package.json @@ -4,7 +4,7 @@ "name": "example-typescript", "dependencies": { "react": "18.2.0", - "react-dom": "^18.2.0", + "react-dom": "18.2.0", "typescript": "^5.0.4" }, "devDependencies": { diff --git a/packages/pretty-format/package.json b/packages/pretty-format/package.json index 7c510b886789..c46ef92d690e 100644 --- a/packages/pretty-format/package.json +++ b/packages/pretty-format/package.json @@ -24,14 +24,14 @@ "react-is": "^18.0.0" }, "devDependencies": { - "@types/react": "^17.0.3", + "@types/react": "^18.2.0", "@types/react-is": "^18.0.0", - "@types/react-test-renderer": "17.0.2", + "@types/react-test-renderer": "^18.0.1", "immutable": "^4.0.0", "jest-util": "workspace:^", - "react": "17.0.2", - "react-dom": "^17.0.1", - "react-test-renderer": "17.0.2" + "react": "18.2.0", + "react-dom": "18.2.0", + "react-test-renderer": "18.2.0" }, "engines": { "node": "^16.10.0 || ^18.12.0 || >=20.0.0" diff --git a/packages/pretty-format/src/__tests__/react.test.tsx b/packages/pretty-format/src/__tests__/react.test.tsx index 97559d5ac6b1..3e2efa33023f 100644 --- a/packages/pretty-format/src/__tests__/react.test.tsx +++ b/packages/pretty-format/src/__tests__/react.test.tsx @@ -48,10 +48,7 @@ test('supports a single element with non-empty string child', () => { }); test('supports a single element with empty string child', () => { - assertPrintedJSX( - React.createElement('Mouse', null, ''), - '\n \n', - ); + assertPrintedJSX(React.createElement('Mouse', null, ''), ''); }); test('supports a single element with non-zero number child', () => { diff --git a/packages/pretty-format/src/plugins/ReactElement.ts b/packages/pretty-format/src/plugins/ReactElement.ts index 7026b690eda2..808ee12114d6 100644 --- a/packages/pretty-format/src/plugins/ReactElement.ts +++ b/packages/pretty-format/src/plugins/ReactElement.ts @@ -21,7 +21,7 @@ const getChildren = (arg: unknown, children: Array = []) => { for (const item of arg) { getChildren(item, children); } - } else if (arg != null && arg !== false) { + } else if (arg != null && arg !== false && arg !== '') { children.push(arg); } return children; diff --git a/website/package.json b/website/package.json index ec01543f4eb4..420e3c26ccb4 100644 --- a/website/package.json +++ b/website/package.json @@ -39,8 +39,8 @@ "@docusaurus/remark-plugin-npm2yarn": "3.0.0-beta.0", "clsx": "^2.0.0", "docusaurus-remark-plugin-tab-blocks": "^2.0.0-beta", - "react": "^18.2.0", - "react-dom": "^18.2.0", + "react": "18.2.0", + "react-dom": "18.2.0", "react-github-btn": "^1.3.0", "react-lite-youtube-embed": "^2.2.2", "react-markdown": "^8.0.0" @@ -50,7 +50,7 @@ "@crowdin/cli": "^3.5.2", "@docusaurus/module-type-aliases": "3.0.0-beta.0", "@docusaurus/tsconfig": "3.0.0-beta.0", - "@types/react": "^18.2.21", + "@types/react": "^18.2.0", "graphql": "^16.3.0", "graphql-request": "^6.0.0", "js-yaml": "^4.1.0", diff --git a/yarn.lock b/yarn.lock index 7f927fd2ffba..ca123f5ebdff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5241,12 +5241,12 @@ __metadata: languageName: node linkType: hard -"@types/react-test-renderer@npm:17.0.2": - version: 17.0.2 - resolution: "@types/react-test-renderer@npm:17.0.2" +"@types/react-test-renderer@npm:^18.0.1": + version: 18.0.2 + resolution: "@types/react-test-renderer@npm:18.0.2" dependencies: - "@types/react": ^17 - checksum: 0be325798b6b38cc31fbb11f2f1e1a5578cc3b23eddf1ddd1ab58ccf50966e8f779383084d8bc3a7db3108ad815af8fbae5c0f54329a88d52200e01547d85c33 + "@types/react": "*" + checksum: 2845b05adcb28180e530b63c47495b2c0beb1a669a0ce962dcfa6ed5b88d37c8438de1f29cb2e599b5f229307a4479e424677407111a571bbcab06bd538ea1df languageName: node linkType: hard @@ -9758,7 +9758,7 @@ __metadata: jest: "workspace:^" jest-environment-jsdom: "workspace:^" react: 18.2.0 - react-dom: ^18.2.0 + react-dom: 18.2.0 languageName: unknown linkType: soft @@ -9773,7 +9773,7 @@ __metadata: jest: "workspace:^" jest-environment-jsdom: "workspace:^" react: 18.2.0 - react-dom: ^18.2.0 + react-dom: 18.2.0 languageName: unknown linkType: soft @@ -9786,8 +9786,8 @@ __metadata: "@babel/preset-react": ^7.12.1 babel-jest: "workspace:^" jest: "workspace:^" - react: 17.0.2 - react-test-renderer: 17.0.2 + react: 18.2.0 + react-test-renderer: 18.2.0 languageName: unknown linkType: soft @@ -9815,7 +9815,7 @@ __metadata: jest: "workspace:^" jest-environment-jsdom: "workspace:^" react: 18.2.0 - react-dom: ^18.2.0 + react-dom: 18.2.0 typescript: ^5.0.4 languageName: unknown linkType: soft @@ -13084,14 +13084,14 @@ __metadata: "@docusaurus/preset-classic": 3.0.0-beta.0 "@docusaurus/remark-plugin-npm2yarn": 3.0.0-beta.0 "@docusaurus/tsconfig": 3.0.0-beta.0 - "@types/react": ^18.2.21 + "@types/react": ^18.2.0 clsx: ^2.0.0 docusaurus-remark-plugin-tab-blocks: ^2.0.0-beta graphql: ^16.3.0 graphql-request: ^6.0.0 js-yaml: ^4.1.0 - react: ^18.2.0 - react-dom: ^18.2.0 + react: 18.2.0 + react-dom: 18.2.0 react-github-btn: ^1.3.0 react-lite-youtube-embed: ^2.2.2 react-markdown: ^8.0.0 @@ -17179,16 +17179,16 @@ __metadata: resolution: "pretty-format@workspace:packages/pretty-format" dependencies: "@jest/schemas": "workspace:^" - "@types/react": ^17.0.3 + "@types/react": ^18.2.0 "@types/react-is": ^18.0.0 - "@types/react-test-renderer": 17.0.2 + "@types/react-test-renderer": ^18.0.1 ansi-styles: ^5.0.0 immutable: ^4.0.0 jest-util: "workspace:^" - react: 17.0.2 - react-dom: ^17.0.1 + react: 18.2.0 + react-dom: 18.2.0 react-is: ^18.0.0 - react-test-renderer: 17.0.2 + react-test-renderer: 18.2.0 languageName: unknown linkType: soft @@ -17551,20 +17551,7 @@ __metadata: languageName: node linkType: hard -"react-dom@npm:^17.0.1": - version: 17.0.2 - resolution: "react-dom@npm:17.0.2" - dependencies: - loose-envify: ^1.1.0 - object-assign: ^4.1.1 - scheduler: ^0.20.2 - peerDependencies: - react: 17.0.2 - checksum: 1c1eaa3bca7c7228d24b70932e3d7c99e70d1d04e13bb0843bbf321582bc25d7961d6b8a6978a58a598af2af496d1cedcfb1bf65f6b0960a0a8161cb8dab743c - languageName: node - linkType: hard - -"react-dom@npm:^18.2.0": +"react-dom@npm:18.2.0": version: 18.2.0 resolution: "react-dom@npm:18.2.0" dependencies: @@ -17631,7 +17618,7 @@ __metadata: languageName: node linkType: hard -"react-is@npm:^17.0.1, react-is@npm:^17.0.2": +"react-is@npm:^17.0.1": version: 17.0.2 resolution: "react-is@npm:17.0.2" checksum: 9d6d111d8990dc98bc5402c1266a808b0459b5d54830bbea24c12d908b536df7883f268a7868cfaedde3dd9d4e0d574db456f84d2e6df9c4526f99bb4b5344d8 @@ -17796,7 +17783,7 @@ __metadata: languageName: node linkType: hard -"react-shallow-renderer@npm:^16.13.1, react-shallow-renderer@npm:^16.15.0": +"react-shallow-renderer@npm:^16.15.0": version: 16.15.0 resolution: "react-shallow-renderer@npm:16.15.0" dependencies: @@ -17808,20 +17795,6 @@ __metadata: languageName: node linkType: hard -"react-test-renderer@npm:17.0.2": - version: 17.0.2 - resolution: "react-test-renderer@npm:17.0.2" - dependencies: - object-assign: ^4.1.1 - react-is: ^17.0.2 - react-shallow-renderer: ^16.13.1 - scheduler: ^0.20.2 - peerDependencies: - react: 17.0.2 - checksum: e6b5c6ed2a0bde2c34f1ab9523ff9bc4c141a271daf730d6b852374e83acc0155d58ab71a318251e953ebfa65b8bebb9c5dce3eba1ccfcbef7cc4e1e8261c401 - languageName: node - linkType: hard - "react-test-renderer@npm:18.2.0": version: 18.2.0 resolution: "react-test-renderer@npm:18.2.0" @@ -17848,17 +17821,7 @@ __metadata: languageName: node linkType: hard -"react@npm:17.0.2": - version: 17.0.2 - resolution: "react@npm:17.0.2" - dependencies: - loose-envify: ^1.1.0 - object-assign: ^4.1.1 - checksum: b254cc17ce3011788330f7bbf383ab653c6848902d7936a87b09d835d091e3f295f7e9dd1597c6daac5dc80f90e778c8230218ba8ad599f74adcc11e33b9d61b - languageName: node - linkType: hard - -"react@npm:18.2.0, react@npm:^18.2.0": +"react@npm:18.2.0": version: 18.2.0 resolution: "react@npm:18.2.0" dependencies: @@ -18630,16 +18593,6 @@ __metadata: languageName: node linkType: hard -"scheduler@npm:^0.20.2": - version: 0.20.2 - resolution: "scheduler@npm:0.20.2" - dependencies: - loose-envify: ^1.1.0 - object-assign: ^4.1.1 - checksum: c4b35cf967c8f0d3e65753252d0f260271f81a81e427241295c5a7b783abf4ea9e905f22f815ab66676f5313be0a25f47be582254db8f9241b259213e999b8fc - languageName: node - linkType: hard - "scheduler@npm:^0.23.0": version: 0.23.0 resolution: "scheduler@npm:0.23.0" From c3f2914b9c0b89960068021fd4483bc45292fbfe Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 19 Sep 2023 13:19:16 +0200 Subject: [PATCH 2/4] chore: upgrade tsd (#14488) --- package.json | 2 +- packages/expect-utils/package.json | 2 +- packages/expect/package.json | 2 +- packages/jest-cli/package.json | 2 +- packages/jest-expect/package.json | 2 +- packages/jest-mock/package.json | 2 +- packages/jest-reporters/package.json | 2 +- packages/jest-resolve/package.json | 2 +- packages/jest-runner/package.json | 2 +- packages/jest-snapshot/package.json | 2 +- packages/jest-types/package.json | 2 +- packages/jest-worker/package.json | 2 +- packages/jest/package.json | 2 +- yarn.lock | 44 ++++++++++++++-------------- 14 files changed, 35 insertions(+), 35 deletions(-) diff --git a/package.json b/package.json index 2cd82837a82b..1783ddb67046 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "jest-changed-files": "workspace:^", "jest-junit": "^16.0.0", "jest-mock": "workspace:^", - "jest-runner-tsd": "^5.0.0", + "jest-runner-tsd": "^6.0.0", "jest-serializer-ansi-escapes": "^2.0.1", "jest-silent-reporter": "^0.5.0", "jest-snapshot": "workspace:^", diff --git a/packages/expect-utils/package.json b/packages/expect-utils/package.json index d5197659c9db..d7ec4d544f89 100644 --- a/packages/expect-utils/package.json +++ b/packages/expect-utils/package.json @@ -23,7 +23,7 @@ "@tsd/typescript": "^5.0.4", "immutable": "^4.0.0", "jest-matcher-utils": "workspace:^", - "tsd-lite": "^0.7.0" + "tsd-lite": "^0.8.0" }, "engines": { "node": "^16.10.0 || ^18.12.0 || >=20.0.0" diff --git a/packages/expect/package.json b/packages/expect/package.json index 96fb564168c7..f148599b95e0 100644 --- a/packages/expect/package.json +++ b/packages/expect/package.json @@ -31,7 +31,7 @@ "@tsd/typescript": "^5.0.4", "chalk": "^4.0.0", "immutable": "^4.0.0", - "tsd-lite": "^0.7.0" + "tsd-lite": "^0.8.0" }, "engines": { "node": "^16.10.0 || ^18.12.0 || >=20.0.0" diff --git a/packages/jest-cli/package.json b/packages/jest-cli/package.json index b29d6cb5fa8a..bb7382453b08 100644 --- a/packages/jest-cli/package.json +++ b/packages/jest-cli/package.json @@ -29,7 +29,7 @@ "@tsd/typescript": "^5.0.4", "@types/exit": "^0.1.30", "@types/yargs": "^17.0.8", - "tsd-lite": "^0.7.0" + "tsd-lite": "^0.8.0" }, "peerDependencies": { "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" diff --git a/packages/jest-expect/package.json b/packages/jest-expect/package.json index 3ec6a7497efe..640941539506 100644 --- a/packages/jest-expect/package.json +++ b/packages/jest-expect/package.json @@ -22,7 +22,7 @@ }, "devDependencies": { "@tsd/typescript": "^5.0.4", - "tsd-lite": "^0.7.0" + "tsd-lite": "^0.8.0" }, "engines": { "node": "^16.10.0 || ^18.12.0 || >=20.0.0" diff --git a/packages/jest-mock/package.json b/packages/jest-mock/package.json index 24c2cb7e68be..ee124ca6e152 100644 --- a/packages/jest-mock/package.json +++ b/packages/jest-mock/package.json @@ -23,7 +23,7 @@ }, "devDependencies": { "@tsd/typescript": "^5.0.4", - "tsd-lite": "^0.7.0" + "tsd-lite": "^0.8.0" }, "engines": { "node": "^16.10.0 || ^18.12.0 || >=20.0.0" diff --git a/packages/jest-reporters/package.json b/packages/jest-reporters/package.json index 5ebf6cfb7403..d2bc1d33de73 100644 --- a/packages/jest-reporters/package.json +++ b/packages/jest-reporters/package.json @@ -52,7 +52,7 @@ "jest-resolve": "workspace:^", "mock-fs": "^5.1.2", "node-notifier": "^10.0.0", - "tsd-lite": "^0.7.0" + "tsd-lite": "^0.8.0" }, "peerDependencies": { "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" diff --git a/packages/jest-resolve/package.json b/packages/jest-resolve/package.json index 11b49ce48523..ae1474137d41 100644 --- a/packages/jest-resolve/package.json +++ b/packages/jest-resolve/package.json @@ -32,7 +32,7 @@ "@types/graceful-fs": "^4.1.3", "@types/pnpapi": "^0.0.2", "@types/resolve": "^1.20.2", - "tsd-lite": "^0.7.0" + "tsd-lite": "^0.8.0" }, "engines": { "node": "^16.10.0 || ^18.12.0 || >=20.0.0" diff --git a/packages/jest-runner/package.json b/packages/jest-runner/package.json index bd0ec7b49e1a..fe0269a8b610 100644 --- a/packages/jest-runner/package.json +++ b/packages/jest-runner/package.json @@ -46,7 +46,7 @@ "@types/graceful-fs": "^4.1.3", "@types/source-map-support": "^0.5.0", "jest-jasmine2": "workspace:^", - "tsd-lite": "^0.7.0" + "tsd-lite": "^0.8.0" }, "engines": { "node": "^16.10.0 || ^18.12.0 || >=20.0.0" diff --git a/packages/jest-snapshot/package.json b/packages/jest-snapshot/package.json index c53b6317fec1..00e78df9b7e1 100644 --- a/packages/jest-snapshot/package.json +++ b/packages/jest-snapshot/package.json @@ -51,7 +51,7 @@ "ansi-regex": "^5.0.1", "ansi-styles": "^5.0.0", "prettier": "^2.1.1", - "tsd-lite": "^0.7.0" + "tsd-lite": "^0.8.0" }, "engines": { "node": "^16.10.0 || ^18.12.0 || >=20.0.0" diff --git a/packages/jest-types/package.json b/packages/jest-types/package.json index 1ac21a8a3759..f2eac7536c9a 100644 --- a/packages/jest-types/package.json +++ b/packages/jest-types/package.json @@ -29,7 +29,7 @@ }, "devDependencies": { "@tsd/typescript": "^5.0.4", - "tsd-lite": "^0.7.0" + "tsd-lite": "^0.8.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-worker/package.json b/packages/jest-worker/package.json index 1dbe257653ea..589ee085f0bc 100644 --- a/packages/jest-worker/package.json +++ b/packages/jest-worker/package.json @@ -29,7 +29,7 @@ "@types/supports-color": "^8.1.0", "get-stream": "^6.0.0", "jest-leak-detector": "workspace:^", - "tsd-lite": "^0.7.0", + "tsd-lite": "^0.8.0", "worker-farm": "^1.6.0" }, "engines": { diff --git a/packages/jest/package.json b/packages/jest/package.json index 21e2081c9fe7..f90d98ccb716 100644 --- a/packages/jest/package.json +++ b/packages/jest/package.json @@ -20,7 +20,7 @@ }, "devDependencies": { "@tsd/typescript": "^5.0.4", - "tsd-lite": "^0.7.0" + "tsd-lite": "^0.8.0" }, "peerDependencies": { "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" diff --git a/yarn.lock b/yarn.lock index ca123f5ebdff..29e847de9b4c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2877,7 +2877,7 @@ __metadata: immutable: ^4.0.0 jest-get-type: "workspace:^" jest-matcher-utils: "workspace:^" - tsd-lite: ^0.7.0 + tsd-lite: ^0.8.0 languageName: unknown linkType: soft @@ -2888,7 +2888,7 @@ __metadata: "@tsd/typescript": ^5.0.4 expect: "workspace:^" jest-snapshot: "workspace:^" - tsd-lite: ^0.7.0 + tsd-lite: ^0.8.0 languageName: unknown linkType: soft @@ -2973,7 +2973,7 @@ __metadata: jest-changed-files: "workspace:^" jest-junit: ^16.0.0 jest-mock: "workspace:^" - jest-runner-tsd: ^5.0.0 + jest-runner-tsd: ^6.0.0 jest-serializer-ansi-escapes: ^2.0.1 jest-silent-reporter: ^0.5.0 jest-snapshot: "workspace:^" @@ -3045,7 +3045,7 @@ __metadata: slash: ^3.0.0 string-length: ^4.0.1 strip-ansi: ^6.0.0 - tsd-lite: ^0.7.0 + tsd-lite: ^0.8.0 v8-to-istanbul: ^9.0.1 peerDependencies: node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 @@ -3192,7 +3192,7 @@ __metadata: "@types/node": "*" "@types/yargs": ^17.0.8 chalk: ^4.0.0 - tsd-lite: ^0.7.0 + tsd-lite: ^0.8.0 languageName: unknown linkType: soft @@ -9858,7 +9858,7 @@ __metadata: jest-matcher-utils: "workspace:^" jest-message-util: "workspace:^" jest-util: "workspace:^" - tsd-lite: ^0.7.0 + tsd-lite: ^0.8.0 languageName: unknown linkType: soft @@ -12502,7 +12502,7 @@ __metadata: jest-config: "workspace:^" jest-util: "workspace:^" jest-validate: "workspace:^" - tsd-lite: ^0.7.0 + tsd-lite: ^0.8.0 yargs: ^17.3.1 peerDependencies: node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 @@ -12746,7 +12746,7 @@ __metadata: "@tsd/typescript": ^5.0.4 "@types/node": "*" jest-util: "workspace:^" - tsd-lite: ^0.7.0 + tsd-lite: ^0.8.0 languageName: unknown linkType: soft @@ -12839,21 +12839,21 @@ __metadata: resolve: ^1.20.0 resolve.exports: ^2.0.0 slash: ^3.0.0 - tsd-lite: ^0.7.0 + tsd-lite: ^0.8.0 languageName: unknown linkType: soft -"jest-runner-tsd@npm:^5.0.0": - version: 5.0.0 - resolution: "jest-runner-tsd@npm:5.0.0" +"jest-runner-tsd@npm:^6.0.0": + version: 6.0.0 + resolution: "jest-runner-tsd@npm:6.0.0" dependencies: "@babel/code-frame": ^7.15.8 chalk: ^4.1.2 create-jest-runner: ^0.12.0 - tsd-lite: ^0.7.0 + tsd-lite: ^0.8.0 peerDependencies: "@tsd/typescript": 4.x || 5.x - checksum: 697db424f8588218eeac9f82ae4c34f79dbbdc2453e19a866a00062f1ea571e24225203cad7e09bdc0c343084997947af3be638a0dc7ce38d866569f5234cf0a + checksum: fb2cf2bfc3ea8b00ffba80aaa3e9c4d1e0ee3597ecadc135ec220e5576d28e610eade3e62d4134584a7e72fea1308e292f7ae2a9e2ebdf70666e4fa64c19ce39 languageName: node linkType: hard @@ -12888,7 +12888,7 @@ __metadata: jest-worker: "workspace:^" p-limit: ^3.1.0 source-map-support: 0.5.13 - tsd-lite: ^0.7.0 + tsd-lite: ^0.8.0 languageName: unknown linkType: soft @@ -12978,7 +12978,7 @@ __metadata: prettier: ^2.1.1 pretty-format: "workspace:^" semver: ^7.5.3 - tsd-lite: ^0.7.0 + tsd-lite: ^0.8.0 languageName: unknown linkType: soft @@ -13113,7 +13113,7 @@ __metadata: jest-util: "workspace:^" merge-stream: ^2.0.0 supports-color: ^8.0.0 - tsd-lite: ^0.7.0 + tsd-lite: ^0.8.0 worker-farm: ^1.6.0 languageName: unknown linkType: soft @@ -13158,7 +13158,7 @@ __metadata: "@tsd/typescript": ^5.0.4 import-local: ^3.0.2 jest-cli: "workspace:^" - tsd-lite: ^0.7.0 + tsd-lite: ^0.8.0 peerDependencies: node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 peerDependenciesMeta: @@ -20027,12 +20027,12 @@ __metadata: languageName: node linkType: hard -"tsd-lite@npm:^0.7.0": - version: 0.7.0 - resolution: "tsd-lite@npm:0.7.0" +"tsd-lite@npm:^0.8.0": + version: 0.8.0 + resolution: "tsd-lite@npm:0.8.0" peerDependencies: "@tsd/typescript": 4.x || 5.x - checksum: 97e304de0bdc906377b213c662b48543fea7e8393f884bc1136d1b9cd731b304bdfefd513d5874b4b9c961fb6462ee40320297c38ec16b7921d0504616dd4c7f + checksum: 7d6b5bdb47d8dc779c66b9a6eac97ca81474b4e9d5acb52692da9e045455b731b36f9925babd98c87ad38685b3170fefef016a0cdf7c46876358c1a0421fffe3 languageName: node linkType: hard From eaa86fbd41777a1ed7009f60705e197a84efc0d8 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 19 Sep 2023 13:19:51 +0200 Subject: [PATCH 3/4] feat: upgrade `@sinonjs/fake-timers` (#14544) --- CHANGELOG.md | 1 + packages/jest-fake-timers/package.json | 2 +- yarn.lock | 10 +++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ccbbcf83e95..af3aa6456259 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Features - `[jest-environment-jsdom]` [**BREAKING**] Upgrade JSDOM to v22 ([#13825](https://github.com/jestjs/jest/pull/13825)) +- `[@jest/fake-timers]` [**BREAKING**] Upgrade `@sinonjs/fake-timers` to v11 ([#14544](https://github.com/jestjs/jest/pull/14544)) - `[@jest/test-sequencer, jest-core]` [**BREAKING**] Exposes `globalConfig` & `contexts` to `TestSequencer` ([#14535](https://github.com/jestjs/jest/pull/14535), & [#14543](https://github.com/jestjs/jest/pull/14543)) - `[pretty-format]` [**BREAKING**] Do not render empty string children (`''`) in React plugin ([#14470](https://github.com/facebook/jest/pull/14470)) diff --git a/packages/jest-fake-timers/package.json b/packages/jest-fake-timers/package.json index 29279d9695d1..29870d18cd42 100644 --- a/packages/jest-fake-timers/package.json +++ b/packages/jest-fake-timers/package.json @@ -18,7 +18,7 @@ }, "dependencies": { "@jest/types": "workspace:^", - "@sinonjs/fake-timers": "^10.0.2", + "@sinonjs/fake-timers": "^11.1.0", "@types/node": "*", "jest-message-util": "workspace:^", "jest-mock": "workspace:^", diff --git a/yarn.lock b/yarn.lock index 29e847de9b4c..9f0910d9e05c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2898,7 +2898,7 @@ __metadata: dependencies: "@jest/test-utils": "workspace:^" "@jest/types": "workspace:^" - "@sinonjs/fake-timers": ^10.0.2 + "@sinonjs/fake-timers": ^11.1.0 "@types/node": "*" "@types/sinonjs__fake-timers": ^8.1.2 jest-message-util: "workspace:^" @@ -4343,12 +4343,12 @@ __metadata: languageName: node linkType: hard -"@sinonjs/fake-timers@npm:^10.0.2": - version: 10.3.0 - resolution: "@sinonjs/fake-timers@npm:10.3.0" +"@sinonjs/fake-timers@npm:^11.1.0": + version: 11.1.0 + resolution: "@sinonjs/fake-timers@npm:11.1.0" dependencies: "@sinonjs/commons": ^3.0.0 - checksum: 614d30cb4d5201550c940945d44c9e0b6d64a888ff2cd5b357f95ad6721070d6b8839cd10e15b76bf5e14af0bcc1d8f9ec00d49a46318f1f669a4bec1d7f3148 + checksum: 9f7690720e640f3abb19e0538b3feab176dc26759397da100e8e1532e617667934693aadfcdd4c42b553963adec4ca6cd70531a5a4853e738d971ad8828a0178 languageName: node linkType: hard From 180bc8b7624f950641aae2d5a358ea62e7df018b Mon Sep 17 00:00:00 2001 From: Ilya Kuznetsov Date: Tue, 19 Sep 2023 15:20:10 +0400 Subject: [PATCH 4/4] chore(jest-cli): Deprecation of the `--init` argument (#14490) --- CHANGELOG.md | 1 + docs/CLI.md | 4 ---- packages/jest-cli/package.json | 1 - packages/jest-cli/src/args.ts | 4 ---- packages/jest-cli/src/run.ts | 7 ------- packages/jest-cli/tsconfig.json | 1 - packages/jest-config/src/Deprecated.ts | 5 +++++ packages/jest-types/src/Config.ts | 1 - yarn.lock | 3 +-- 9 files changed, 7 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af3aa6456259..b83b0cc10e6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ ### Chore & Maintenance - `[*]` [**BREAKING**] Drop support for Node.js versions 14 and 19 ([#14460](https://github.com/jestjs/jest/pull/14460)) +- `[jest-cli, jest-config, @jest/types]` [**BREAKING**] Remove deprecated `--init` argument ([#14490](https://github.com/jestjs/jest/pull/14490)) ## 29.7.0 diff --git a/docs/CLI.md b/docs/CLI.md index f57c83cc0988..033fa6a83069 100644 --- a/docs/CLI.md +++ b/docs/CLI.md @@ -230,10 +230,6 @@ Show the help information, similar to this page. Ignore the tests of the specified projects. Jest uses the attribute `displayName` in the configuration to identify each project. If you use this option, you should provide a `displayName` to all your projects. -### `--init` - -Generate a basic configuration file. Based on your project, Jest will ask you a few questions that will help to generate a `jest.config.js` file with a short description for each option. - ### `--injectGlobals` Insert Jest's globals (`expect`, `test`, `describe`, `beforeEach` etc.) into the global environment. If you set this to `false`, you should import from `@jest/globals`, e.g. diff --git a/packages/jest-cli/package.json b/packages/jest-cli/package.json index bb7382453b08..ef828a2cbec1 100644 --- a/packages/jest-cli/package.json +++ b/packages/jest-cli/package.json @@ -17,7 +17,6 @@ "@jest/test-result": "workspace:^", "@jest/types": "workspace:^", "chalk": "^4.0.0", - "create-jest": "workspace:^", "exit": "^0.1.2", "import-local": "^3.0.2", "jest-config": "workspace:^", diff --git a/packages/jest-cli/src/args.ts b/packages/jest-cli/src/args.ts index 56d21754c926..869f1a0a707f 100644 --- a/packages/jest-cli/src/args.ts +++ b/packages/jest-cli/src/args.ts @@ -309,10 +309,6 @@ export const options: {[key: string]: Options} = { string: true, type: 'array', }, - init: { - description: 'Generate a basic configuration file', - type: 'boolean', - }, injectGlobals: { description: 'Should Jest inject global variables or not', type: 'boolean', diff --git a/packages/jest-cli/src/run.ts b/packages/jest-cli/src/run.ts index 1f08f7931cf4..3c6babcbe921 100644 --- a/packages/jest-cli/src/run.ts +++ b/packages/jest-cli/src/run.ts @@ -12,7 +12,6 @@ import yargs = require('yargs'); import {getVersion, runCLI} from '@jest/core'; import type {AggregatedResult} from '@jest/test-result'; import type {Config} from '@jest/types'; -import {runCreate} from 'create-jest'; import {deprecationEntries} from 'jest-config'; import {clearLine, tryRealpath} from 'jest-util'; import {validateCLIOptions} from 'jest-validate'; @@ -24,12 +23,6 @@ export async function run( ): Promise { try { const argv = await buildArgv(maybeArgv); - - if (argv.init) { - await runCreate(); - return; - } - const projects = getProjectListFromCLIArgs(argv, project); const {results, globalConfig} = await runCLI(argv, projects); diff --git a/packages/jest-cli/tsconfig.json b/packages/jest-cli/tsconfig.json index dabfdb21d4c4..32f96c0f8a77 100644 --- a/packages/jest-cli/tsconfig.json +++ b/packages/jest-cli/tsconfig.json @@ -7,7 +7,6 @@ "include": ["./src/**/*"], "exclude": ["./**/__tests__/**/*"], "references": [ - {"path": "../create-jest"}, {"path": "../jest-config"}, {"path": "../jest-core"}, {"path": "../jest-test-result"}, diff --git a/packages/jest-config/src/Deprecated.ts b/packages/jest-config/src/Deprecated.ts index e1f3239a833f..be90f76d75d6 100644 --- a/packages/jest-config/src/Deprecated.ts +++ b/packages/jest-config/src/Deprecated.ts @@ -28,6 +28,11 @@ const deprecatedOptions: DeprecatedOptions = { Please update your configuration.`, + init: () => + ` Option ${chalk.bold( + '"init"', + )} has been deprecated. Please use "create-jest" package as shown in the documentation: https://jestjs.io/docs/getting-started#generate-a-basic-configuration-file`, + moduleLoader: (_options: {moduleLoader?: string}) => ` Option ${chalk.bold( '"moduleLoader"', )} was replaced by ${chalk.bold('"runtime"')}. diff --git a/packages/jest-types/src/Config.ts b/packages/jest-types/src/Config.ts index 307dee61f30a..589e7b6cd3f3 100644 --- a/packages/jest-types/src/Config.ts +++ b/packages/jest-types/src/Config.ts @@ -526,7 +526,6 @@ export type Argv = Arguments< globalTeardown: string | null | undefined; haste: string; ignoreProjects: Array; - init: boolean; injectGlobals: boolean; json: boolean; lastCommit: boolean; diff --git a/yarn.lock b/yarn.lock index 9f0910d9e05c..175fbe4feba0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8055,7 +8055,7 @@ __metadata: languageName: node linkType: hard -"create-jest@workspace:^, create-jest@workspace:packages/create-jest": +"create-jest@workspace:packages/create-jest": version: 0.0.0-use.local resolution: "create-jest@workspace:packages/create-jest" dependencies: @@ -12496,7 +12496,6 @@ __metadata: "@types/exit": ^0.1.30 "@types/yargs": ^17.0.8 chalk: ^4.0.0 - create-jest: "workspace:^" exit: ^0.1.2 import-local: ^3.0.2 jest-config: "workspace:^"