Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3122be2
chore: Update Jest related packages to ^28
Gudahtt Nov 17, 2025
6c035dd
Add workaround for uuid incompatibility
Gudahtt Nov 17, 2025
608af12
WIP
Gudahtt Nov 17, 2025
b1fe19d
WIP
Gudahtt Nov 17, 2025
b753669
Explicitly specify environments and update them
Gudahtt Nov 17, 2025
91d8b82
Update to fix bug with fake timers
Gudahtt Nov 17, 2025
c7ce6b1
Fix depcheck lint error
Gudahtt Nov 19, 2025
fa93c24
Update test enviornment imports
Gudahtt Nov 19, 2025
6f4bdf0
Use modern timers everywhere (we already do on main, using legacy was…
Gudahtt Nov 19, 2025
9b947d4
Fix lint error
Gudahtt Nov 19, 2025
54a41ee
fix: ensure nock can intercept fetch requests in Jest 28
cryptodev-2s Nov 22, 2025
989ed2b
fix: add export statement to make setup.ts unambiguous module
cryptodev-2s Nov 22, 2025
12dc701
fix tests
cryptodev-2s Nov 25, 2025
b498c3b
Fix Jest 28 compatibility and formatting
cryptodev-2s Nov 27, 2025
6e9bd12
chore: update yarn.lock for Jest 28 compatibility
cryptodev-2s Nov 27, 2025
8fc024b
fix: dedupe deps
cryptodev-2s Nov 27, 2025
c61401a
fix: resolve YN0078 error for @metamask/eth-json-rpc-provider
cryptodev-2s Nov 27, 2025
676393f
Merge remote-tracking branch 'origin/main' into fix/nock-jest28-compa…
cryptodev-2s Feb 2, 2026
67acb78
fix: update Jest 28 compatibility for jest-environment packages
cryptodev-2s Feb 2, 2026
e194052
fix: resolve ESLint errors for uuid and import-x/no-unassigned-import
cryptodev-2s Feb 2, 2026
1564b22
fix: update remaining packages to Jest 28 versions
cryptodev-2s Feb 2, 2026
4545646
fix: update permission-log-controller tests for Jest 28 compatibility
cryptodev-2s Feb 2, 2026
83a183d
fix: update remote-feature-flag-controller test for Jest 28 compatibi…
cryptodev-2s Feb 2, 2026
279f00a
Merge branch 'main' into chore/migrate-jest-to-v28-2
cryptodev-2s Feb 2, 2026
43a1b65
refactor: use named import for jest-environment-jsdom TestEnvironment
cryptodev-2s Feb 2, 2026
d51b405
fix: .depcheckrc.yml
cryptodev-2s Feb 2, 2026
3cf47ab
chore: update to latest Jest 28 versions
cryptodev-2s Feb 2, 2026
5bf18b8
ci: increase Node.js heap size for lint step
cryptodev-2s Feb 2, 2026
2a7c0cd
Merge branch 'main' into chore/migrate-jest-to-v28-2
cryptodev-2s Feb 3, 2026
46f6d91
Merge branch 'main' into chore/migrate-jest-to-v28-2
cryptodev-2s Feb 3, 2026
acb8a43
fix: remove unrelated changes
cryptodev-2s Feb 3, 2026
6ae810c
fix: @typescript-eslint/prefer-optional-chain
cryptodev-2s Feb 3, 2026
544b955
fix: package-template jest versions
cryptodev-2s Feb 3, 2026
f2a8c6f
Merge branch 'main' into chore/migrate-jest-to-v28-2
cryptodev-2s Feb 3, 2026
3cbe600
Merge branch 'main' into chore/migrate-jest-to-v28-2
cryptodev-2s Feb 4, 2026
281fd9d
Merge remote-tracking branch 'origin/main' into chore/migrate-jest-to…
cryptodev-2s Feb 4, 2026
a0772db
Merge branch 'main' into chore/migrate-jest-to-v28-2
cryptodev-2s Feb 4, 2026
0f0c19d
Merge branch 'main' into chore/migrate-jest-to-v28-2
cryptodev-2s Feb 5, 2026
ff28ddb
Merge branch 'main' into chore/migrate-jest-to-v28-2
cryptodev-2s Feb 5, 2026
eec189c
Merge remote-tracking branch 'origin/main' into chore/migrate-jest-to…
cryptodev-2s Feb 6, 2026
87d2dda
Merge branch 'main' into chore/migrate-jest-to-v28-2
cryptodev-2s Feb 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ ignores:
- 'jest-silent-reporter'
- 'prettier-plugin-packagejson'
- 'typescript-eslint'
# Jest environment referenced in `jest.config.scripts.js`
- 'jest-environment-node'
- 'jest-environment-jsdom'
# Ignore dependencies imported implicitly by tools
- 'eslint-import-resolver-typescript'
# Ignore dependencies which plug into the NPM lifecycle
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/lint-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
- run: yarn lint
env:
NODE_OPTIONS: '--max-old-space-size=8192'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in our meeting earlier, what do you think about extracting this to a separate PR? We could either use --max-old-space-size or --max-semi-space-size as suggested in the document that Mark linked to earlier.

- name: Require clean working directory
shell: bash
run: |
Expand Down
19 changes: 17 additions & 2 deletions jest.config.packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ module.exports = {
// so in that case use their published versions
'<rootDir>/../../node_modules/@metamask/$1',
],
'^uuid$': require.resolve('uuid'),
},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
Expand All @@ -103,6 +104,18 @@ module.exports = {
// A preset that is used as a base for Jest's configuration
preset: 'ts-jest',

// ts-jest configuration - use isolatedModules to skip type checking during tests
// Type checking should be done separately via `yarn build:types` or the IDE
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
isolatedModules: true,
diagnostics: false,
},
],
},

// The path to the Prettier executable used to format snapshots
// Jest doesn't support Prettier 3 yet, so we use Prettier 2
prettierPath: require.resolve('prettier-2'),
Expand Down Expand Up @@ -188,8 +201,10 @@ module.exports = {
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",

// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",
// Enabling fake timers allows the use of fake timers for functions such as "setTimeout"
// fakeTimers: {
// enableGlobally: false,
// },

// A map from regular expressions to paths to transformers
// transform: undefined,
Expand Down
6 changes: 1 addition & 5 deletions jest.config.scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ module.exports = {
},
},

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// This ensures that Babel can resolve subpath exports correctly.
moduleNameMapper: {
'^@metamask/utils/(.+)$': [
'<rootDir>/node_modules/@metamask/utils/dist/$1.cjs',
],
'^uuid$': require.resolve('uuid'),
},

// Disabled due to use of 'transform' below.
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@metamask/network-controller": "^29.0.0",
"@metamask/utils": "^11.9.0",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"@types/lodash": "^4.14.191",
"@types/node": "^16.18.54",
"@types/semver": "^7",
Expand All @@ -87,7 +87,7 @@
"eslint-plugin-promise": "^7.1.0",
"execa": "^5.0.0",
"isomorphic-fetch": "^3.0.0",
"jest": "^27.5.1",
"jest": "^28.1.3",
"jest-silent-reporter": "^0.5.0",
"lodash": "^4.17.21",
"nock": "^13.3.1",
Expand All @@ -100,6 +100,7 @@
"tsx": "^4.20.5",
"typescript": "~5.3.3",
"typescript-eslint": "^8.48.0",
"uuid": "^8.3.2",
"yargs": "^17.7.2"
},
"packageManager": "yarn@4.10.3",
Expand Down
6 changes: 3 additions & 3 deletions packages/account-tree-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
"@metamask/keyring-api": "^21.0.0",
"@metamask/providers": "^22.1.0",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"ts-jest": "^27.1.5",
"jest": "^28.1.3",
"ts-jest": "^28.0.8",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.3.3",
Expand Down
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was made because CI was failing here https://github.com/MetaMask/core/actions/runs/21633770562/job/62353444019

error  Prefer using an optional chain expression instead, as it's more concise and easier to read  @typescript-eslint/prefer-optional-chain

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like these errors are showing up now because we are able to run yarn lint on the full monorepo thanks to the --max-old-space-size option you added above. When extracting a PR for that option, should we also include these changes?

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const getLocalGroupForEntropyWallet = (
const walletId = toMultichainAccountWalletId(entropySourceId);
const wallet = context.controller.state.accountTree.wallets[walletId];

if (!wallet || wallet.type !== AccountWalletType.Entropy) {
if (wallet?.type !== AccountWalletType.Entropy) {
backupAndSyncLogger(
`Wallet ${walletId} not found or is not an entropy wallet`,
);
Expand All @@ -65,7 +65,7 @@ export function getLocalGroupsForEntropyWallet(
walletId: AccountWalletId,
): AccountGroupMultichainAccountObject[] {
const wallet = context.controller.state.accountTree.wallets[walletId];
if (!wallet || wallet.type !== AccountWalletType.Entropy) {
if (wallet?.type !== AccountWalletType.Entropy) {
backupAndSyncLogger(
`Wallet ${walletId} not found or is not an entropy wallet`,
);
Expand Down
6 changes: 3 additions & 3 deletions packages/accounts-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
"@metamask/controller-utils": "^11.18.0",
"@metamask/providers": "^22.1.0",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"@types/readable-stream": "^2.3.0",
"jest": "^27.5.1",
"ts-jest": "^27.1.5",
"jest": "^28.1.3",
"ts-jest": "^28.0.8",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.3.3",
Expand Down
6 changes: 3 additions & 3 deletions packages/address-book-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"ts-jest": "^27.1.5",
"jest": "^28.1.3",
"ts-jest": "^28.0.8",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.3.3"
Expand Down
6 changes: 3 additions & 3 deletions packages/ai-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"ts-jest": "^27.1.5",
"jest": "^28.1.3",
"ts-jest": "^28.0.8",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.3.3"
Expand Down
6 changes: 3 additions & 3 deletions packages/analytics-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"ts-jest": "^27.1.5",
"jest": "^28.1.3",
"ts-jest": "^28.0.8",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.3.3"
Expand Down
6 changes: 3 additions & 3 deletions packages/analytics-data-regulation-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"jest": "^28.1.3",
"nock": "^13.3.1",
"sinon": "^9.2.4",
"ts-jest": "^27.1.5",
"ts-jest": "^28.0.8",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.3.3"
Expand Down
6 changes: 3 additions & 3 deletions packages/announcement-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"ts-jest": "^27.1.5",
"jest": "^28.1.3",
"ts-jest": "^28.0.8",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.3.3"
Expand Down
6 changes: 3 additions & 3 deletions packages/app-metadata-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"jest": "^28.1.3",
"sinon": "^9.2.4",
"ts-jest": "^27.1.5",
"ts-jest": "^28.0.8",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.3.3"
Expand Down
6 changes: 3 additions & 3 deletions packages/approval-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"jest": "^28.1.3",
"sinon": "^9.2.4",
"ts-jest": "^27.1.5",
"ts-jest": "^28.0.8",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.3.3"
Expand Down
6 changes: 3 additions & 3 deletions packages/assets-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"@types/lodash": "^4.14.191",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"ts-jest": "^27.1.5",
"jest": "^28.1.3",
"ts-jest": "^28.0.8",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.3.3"
Expand Down
4 changes: 2 additions & 2 deletions packages/assets-controllers/jest.environment.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const JSDOMEnvironment = require('jest-environment-jsdom');
const { TestEnvironment } = require('jest-environment-jsdom');

// Custom test environment copied from https://github.com/jsdom/jsdom/issues/2524
// in order to add TextEncoder to jsdom. TextEncoder is expected by jose.

module.exports = class CustomTestEnvironment extends JSDOMEnvironment {
module.exports = class CustomTestEnvironment extends TestEnvironment {
async setup() {
await super.setup();
if (typeof this.global.TextEncoder === 'undefined') {
Expand Down
8 changes: 4 additions & 4 deletions packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@
"@metamask/keyring-snap-client": "^8.0.0",
"@metamask/providers": "^22.1.0",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"@types/lodash": "^4.14.191",
"@types/node": "^16.18.54",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"jest-environment-jsdom": "^27.5.1",
"jest": "^28.1.3",
"jest-environment-jsdom": "^29.0.0",
"nock": "^13.3.1",
"sinon": "^9.2.4",
"ts-jest": "^27.1.5",
"ts-jest": "^28.0.8",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.3.3",
Expand Down
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was made because CI was failing here https://github.com/MetaMask/core/actions/runs/21633770562/job/62353444019

error  Prefer using an optional chain expression instead, as it's more concise and easier to read  @typescript-eslint/prefer-optional-chain

Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ export class DeFiPositionsController extends StaticIntervalPollingController()<
const selectedAddress = this.#getSelectedEvmAdress();

if (
!selectedAddress ||
selectedAddress.toLowerCase() !==
transactionMeta.txParams.from.toLowerCase()
selectedAddress?.toLowerCase() !==
transactionMeta.txParams.from.toLowerCase()
) {
return;
}
Expand Down
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was made because CI was failing here https://github.com/MetaMask/core/actions/runs/21633770562/job/62353444019

error  Prefer using an optional chain expression instead, as it's more concise and easier to read  @typescript-eslint/prefer-optional-chain

Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,7 @@ export class TokenBalancesController extends StaticIntervalPollingController<{
const stakingContractAddress =
STAKING_CONTRACT_ADDRESS_BY_CHAINID[balance.chainId];
return (
stakingContractAddress &&
stakingContractAddress.toLowerCase() === balance.token.toLowerCase()
stakingContractAddress?.toLowerCase() === balance.token.toLowerCase()
);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/assets-controllers/src/TokenListController.ts
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was made because CI was failing here https://github.com/MetaMask/core/actions/runs/21633770562/job/62353444019

error  Prefer using an optional chain expression instead, as it's more concise and easier to read  @typescript-eslint/prefer-optional-chain

Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export class TokenListController extends StaticIntervalPollingController<TokenLi
const prevData = this.#previousTokensChainsCache[chainId];

// Chain is new or timestamp changed (indicating data update)
if (!prevData || prevData.timestamp !== newData.timestamp) {
if (prevData?.timestamp !== newData.timestamp) {
this.#changedChainsToPersist.add(chainId);
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/base-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
"@metamask/auto-changelog": "^3.4.4",
"@metamask/json-rpc-engine": "^10.2.2",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"@types/sinon": "^9.0.10",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"jest": "^28.1.3",
"sinon": "^9.2.4",
"ts-jest": "^27.1.5",
"ts-jest": "^28.0.8",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.3.3"
Expand Down
8 changes: 4 additions & 4 deletions packages/bridge-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@
"@metamask/eth-json-rpc-provider": "^6.0.0",
"@metamask/superstruct": "^3.1.0",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"jest-environment-jsdom": "^27.5.1",
"jest": "^28.1.3",
"jest-environment-jsdom": "^29.0.0",
"lodash": "^4.17.21",
"nock": "^13.3.1",
"ts-jest": "^27.1.5",
"ts-jest": "^28.0.8",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.3.3"
Expand Down
8 changes: 4 additions & 4 deletions packages/bridge-status-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"jest-environment-jsdom": "^27.5.1",
"jest": "^28.1.3",
"jest-environment-jsdom": "^29.0.0",
"lodash": "^4.17.21",
"nock": "^13.3.1",
"ts-jest": "^27.1.5",
"ts-jest": "^28.0.8",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.3.3"
Expand Down
Loading