Skip to content

Commit 04367f0

Browse files
committed
chore: migrate Jest from v27 to v28
1 parent a2ee4a6 commit 04367f0

File tree

81 files changed

+1154
-1024
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1154
-1024
lines changed

jest.config.packages.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ module.exports = {
8080
// Here we ensure that Jest resolves `@metamask/*` imports to the uncompiled source code for packages that live in this repo.
8181
// NOTE: This must be synchronized with the `paths` option in `tsconfig.base.json`.
8282
moduleNameMapper: {
83+
// Force uuid and yaml to use CommonJS versions to avoid ESM issues
84+
'^uuid$': '<rootDir>/../../node_modules/uuid/dist/index.js',
85+
'^yaml$': '<rootDir>/../../node_modules/yaml/dist/index.js',
8386
'^@metamask/json-rpc-engine/v2$': [
8487
'<rootDir>/../json-rpc-engine/src/v2/index.ts',
8588
],
@@ -195,7 +198,8 @@ module.exports = {
195198
// transform: undefined,
196199

197200
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
198-
// transformIgnorePatterns: undefined
201+
// Transform ESM modules from node_modules that need to be processed
202+
transformIgnorePatterns: ['/node_modules/(?!(uuid|yaml)/)'],
199203

200204
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
201205
// unmockedModulePathPatterns: undefined,

jest.config.scripts.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* NOTE:
66
* This config uses `babel-jest` due to ESM- / TypeScript-related incompatibilities with our
7-
* current version (`^27`) of `jest` and `ts-jest`. We can switch to `ts-jest` once we have
7+
* current version (`^28`) of `jest` and `ts-jest`. We can switch to `ts-jest` once we have
88
* migrated our Jest dependencies to version `>=29`.
99
*/
1010

@@ -41,11 +41,17 @@ module.exports = {
4141
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
4242
// This ensures that Babel can resolve subpath exports correctly.
4343
moduleNameMapper: {
44+
// Force uuid to use CommonJS version to avoid ESM issues
45+
'^uuid$': '<rootDir>/node_modules/uuid/dist/index.js',
4446
'^@metamask/utils/(.+)$': [
4547
'<rootDir>/node_modules/@metamask/utils/dist/$1.cjs',
4648
],
4749
},
4850

51+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
52+
// Transform ESM modules from node_modules that need to be processed
53+
transformIgnorePatterns: ['node_modules/(?!(uuid)/)'],
54+
4955
// Disabled due to use of 'transform' below.
5056
// // A preset that is used as a base for Jest's configuration
5157
// preset: 'ts-jest',

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"@metamask/network-controller": "^29.0.0",
6767
"@metamask/utils": "^11.9.0",
6868
"@ts-bridge/cli": "^0.6.4",
69-
"@types/jest": "^27.4.1",
69+
"@types/jest": "^28.1.8",
7070
"@types/lodash": "^4.14.191",
7171
"@types/node": "^16.18.54",
7272
"@types/semver": "^7",
@@ -87,7 +87,8 @@
8787
"eslint-plugin-promise": "^7.1.0",
8888
"execa": "^5.0.0",
8989
"isomorphic-fetch": "^3.0.0",
90-
"jest": "^27.5.1",
90+
"jest": "^28.1.3",
91+
"jest-environment-jsdom": "^28.1.3",
9192
"jest-silent-reporter": "^0.5.0",
9293
"lodash": "^4.17.21",
9394
"nock": "^13.3.1",

packages/account-tree-controller/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@
6868
"@metamask/keyring-api": "^21.0.0",
6969
"@metamask/providers": "^22.1.0",
7070
"@ts-bridge/cli": "^0.6.4",
71-
"@types/jest": "^27.4.1",
71+
"@types/jest": "^28.1.8",
7272
"deepmerge": "^4.2.2",
73-
"jest": "^27.5.1",
74-
"ts-jest": "^27.1.4",
73+
"jest": "^28.1.3",
74+
"ts-jest": "^28.0.8",
7575
"typedoc": "^0.24.8",
7676
"typedoc-plugin-missing-exports": "^2.0.0",
7777
"typescript": "~5.3.3",

packages/accounts-controller/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@
7373
"@metamask/controller-utils": "^11.18.0",
7474
"@metamask/providers": "^22.1.0",
7575
"@ts-bridge/cli": "^0.6.4",
76-
"@types/jest": "^27.4.1",
76+
"@types/jest": "^28.1.8",
7777
"@types/readable-stream": "^2.3.0",
78-
"jest": "^27.5.1",
79-
"ts-jest": "^27.1.4",
78+
"jest": "^28.1.3",
79+
"ts-jest": "^28.0.8",
8080
"typedoc": "^0.24.8",
8181
"typedoc-plugin-missing-exports": "^2.0.0",
8282
"typescript": "~5.3.3",

packages/address-book-controller/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@
5656
"devDependencies": {
5757
"@metamask/auto-changelog": "^3.4.4",
5858
"@ts-bridge/cli": "^0.6.4",
59-
"@types/jest": "^27.4.1",
59+
"@types/jest": "^28.1.8",
6060
"deepmerge": "^4.2.2",
61-
"jest": "^27.5.1",
62-
"ts-jest": "^27.1.4",
61+
"jest": "^28.1.3",
62+
"ts-jest": "^28.0.8",
6363
"typedoc": "^0.24.8",
6464
"typedoc-plugin-missing-exports": "^2.0.0",
6565
"typescript": "~5.3.3"

packages/ai-controllers/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050
"devDependencies": {
5151
"@metamask/auto-changelog": "^3.4.4",
5252
"@ts-bridge/cli": "^0.6.4",
53-
"@types/jest": "^27.4.1",
53+
"@types/jest": "^28.1.8",
5454
"deepmerge": "^4.2.2",
55-
"jest": "^27.5.1",
56-
"ts-jest": "^27.1.4",
55+
"jest": "^28.1.3",
56+
"ts-jest": "^28.0.8",
5757
"typedoc": "^0.24.8",
5858
"typedoc-plugin-missing-exports": "^2.0.0",
5959
"typescript": "~5.3.3"

packages/analytics-controller/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@
5555
"devDependencies": {
5656
"@metamask/auto-changelog": "^3.4.4",
5757
"@ts-bridge/cli": "^0.6.4",
58-
"@types/jest": "^27.4.1",
58+
"@types/jest": "^28.1.8",
5959
"deepmerge": "^4.2.2",
60-
"jest": "^27.5.1",
61-
"ts-jest": "^27.1.4",
60+
"jest": "^28.1.3",
61+
"ts-jest": "^28.0.8",
6262
"typedoc": "^0.24.8",
6363
"typedoc-plugin-missing-exports": "^2.0.0",
6464
"typescript": "~5.3.3"

packages/analytics-data-regulation-controller/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@
5656
"devDependencies": {
5757
"@metamask/auto-changelog": "^3.4.4",
5858
"@ts-bridge/cli": "^0.6.4",
59-
"@types/jest": "^27.4.1",
59+
"@types/jest": "^28.1.8",
6060
"deepmerge": "^4.2.2",
61-
"jest": "^27.5.1",
61+
"jest": "^28.1.3",
6262
"nock": "^13.3.1",
6363
"sinon": "^9.2.4",
64-
"ts-jest": "^27.1.4",
64+
"ts-jest": "^28.0.8",
6565
"typedoc": "^0.24.8",
6666
"typedoc-plugin-missing-exports": "^2.0.0",
6767
"typescript": "~5.3.3"

packages/announcement-controller/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
"devDependencies": {
5555
"@metamask/auto-changelog": "^3.4.4",
5656
"@ts-bridge/cli": "^0.6.4",
57-
"@types/jest": "^27.4.1",
57+
"@types/jest": "^28.1.8",
5858
"deepmerge": "^4.2.2",
59-
"jest": "^27.5.1",
60-
"ts-jest": "^27.1.4",
59+
"jest": "^28.1.3",
60+
"ts-jest": "^28.0.8",
6161
"typedoc": "^0.24.8",
6262
"typedoc-plugin-missing-exports": "^2.0.0",
6363
"typescript": "~5.3.3"

0 commit comments

Comments
 (0)