Skip to content

Commit 91f37e1

Browse files
authored
Add test:clean build script that clears jest cache before running tests (#1714)
## Motivation Clearing jest cache can be necessary for debugging, especially when dealing with dependency version changes. Adding this functionality as a build script will make it more visible to future contributors as an available option for troubleshooting. ## Additions - A new `test:clean` build script that runs `jest --clearCache` in every submodule of the monorepo, and then runs the existing `test` script. - Originally attempted to have each submodule run `jest --clearCache && jest`, but this causes issues with failed tests due to concurrent read/writes to the jest cache directory. - A `constraint.pro` entry that will enforce the addition of a `test:clean` script in future submodules. ## Changelog N/A
1 parent 897ba05 commit 91f37e1

File tree

26 files changed

+30
-1
lines changed

26 files changed

+30
-1
lines changed

constraints.pro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ gen_enforced_field(WorkspaceCwd, 'scripts.changelog:validate', ProperChangelogVa
257257
gen_enforced_field(WorkspaceCwd, 'scripts.test', 'jest') :-
258258
WorkspaceCwd \= '.'.
259259

260+
% All non-root packages must have the same "test:clean" script.
261+
gen_enforced_field(WorkspaceCwd, 'scripts.test:clean', 'jest --clearCache') :-
262+
WorkspaceCwd \= '.'.
263+
260264
% All non-root packages must have the same "test:watch" script.
261265
gen_enforced_field(WorkspaceCwd, 'scripts.test:watch', 'jest --watch') :-
262266
WorkspaceCwd \= '.'.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"prepare-preview-builds": "./scripts/prepare-preview-builds.sh",
2828
"publish-previews": "yarn workspaces foreach --parallel --verbose run publish:preview",
2929
"setup": "yarn install",
30-
"test": "yarn workspaces foreach --parallel --verbose run test"
30+
"test": "yarn workspaces foreach --parallel --verbose run test",
31+
"test:clean": "yarn workspaces foreach --parallel --verbose run test:clean && yarn test"
3132
},
3233
"simple-git-hooks": {
3334
"pre-push": "yarn lint"

packages/accounts-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/accounts-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/address-book-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/address-book-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/announcement-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/announcement-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/approval-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/approval-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/assets-controllers/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/assets-controllers",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/base-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/base-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/composable-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/composable-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/controller-utils/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/controller-utils",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/ens-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/ens-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/gas-fee-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/gas-fee-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/keyring-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/keyring-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/logging-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/logging-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/message-manager/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/message-manager",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/name-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"prepare-manifest:preview": "../../scripts/prepare-preview-manifest.sh",
2727
"publish:preview": "yarn npm publish --tag preview",
2828
"test": "jest",
29+
"test:clean": "jest --clearCache",
2930
"test:watch": "jest --watch"
3031
},
3132
"dependencies": {

packages/network-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/network-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/notification-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/notification-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/permission-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/permission-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/phishing-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/phishing-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/polling-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/polling-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/preferences-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/preferences-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/rate-limit-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/rate-limit-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/selected-network-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/selected-network-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/signature-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/signature-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

packages/transaction-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/transaction-controller",
2626
"publish:preview": "yarn npm publish --tag preview",
2727
"test": "jest",
28+
"test:clean": "jest --clearCache",
2829
"test:watch": "jest --watch"
2930
},
3031
"dependencies": {

0 commit comments

Comments
 (0)