Skip to content

Commit 89448bc

Browse files
authored
refactor: Clear jest's cache without validating jest configs (#3312)
This pull request updates the `clean` script in the `package.json` files across multiple packages to improve how Jest's cache is cleared. The script now explicitly provides an empty config to the `jest --clearCache` command, which helps prevent issues if a local or default Jest config is missing or incompatible. > [!IMPORTANT] > It still clears the default cache directory, but! it does not care about config file validity.[^1] ### Changes **Script improvements across all packages:** * Updated the `clean` script in the following `package.json` files to use `jest --clearCache --config '{}'` instead of just `jest --clearCache`, ensuring Jest does not look for a config file when clearing its cache: - `packages/autocertifier-server/package.json` - `packages/cdn-location/package.json` - `packages/cli-tools/package.json` - `packages/dht/package.json` - `packages/geoip-location/package.json` - `packages/node/package.json` - `packages/proto-rpc/package.json` - `packages/sdk/package.json` - `packages/test-utils/package.json` - `packages/trackerless-network/package.json` - `packages/utils/package.json` This also noticeably speeds up the cleanup process. [^1]: Configs can \*become* invalid due to the processing order of the `npm run … --workspaces` command – `clean` command of the most "shared" test package (like `test-utils`) gets called first which may (will) in the future cause deletion of its jest setup files used by some packages in their jest setups (like custom matchers).
1 parent 91c09c8 commit 89448bc

File tree

11 files changed

+11
-11
lines changed

11 files changed

+11
-11
lines changed

packages/autocertifier-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"scripts": {
2727
"build": "tsc -b",
2828
"check": "tsc -p tsconfig.jest.json",
29-
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
29+
"clean": "jest --clearCache --config '{}' || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
3030
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
3131
"test": "jest test/unit test/integration",
3232
"test-unit": "jest test/unit",

packages/cdn-location/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"scripts": {
2121
"build": "tsc -b",
2222
"check": "tsc -p tsconfig.jest.json",
23-
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
23+
"clean": "jest --clearCache --config '{}' || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
2424
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
2525
"test": "jest test/integration",
2626
"test-integration": "jest test/integration",

packages/cli-tools/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"scripts": {
2020
"build": "tsc -b",
2121
"check": "tsc -p tsconfig.jest.json",
22-
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
22+
"clean": "jest --clearCache --config '{}' || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
2323
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
2424
"test": "npm run build && jest --bail --forceExit"
2525
},

packages/dht/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"build": "tsc -b",
2828
"build-browser": "webpack --mode=development --progress",
2929
"check": "tsc -p tsconfig.jest.json",
30-
"clean": "jest --clearCache || true; rm -rf dist generated *.tsbuildinfo node_modules/.cache || true",
30+
"clean": "jest --clearCache --config '{}' || true; rm -rf dist generated *.tsbuildinfo node_modules/.cache || true",
3131
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
3232
"test": "npm run test-unit && npm run test-integration && npm run test-end-to-end",
3333
"test-browser": "karma start karma.config.ts",

packages/geoip-location/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"scripts": {
2626
"build": "tsc -b",
2727
"check": "tsc -p tsconfig.jest.json",
28-
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
28+
"clean": "jest --clearCache --config '{}' || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
2929
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
3030
"test": "jest test/unit",
3131
"test-unit": "jest test/unit"

packages/node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"scripts": {
2828
"build": "tsc -b",
2929
"check": "tsc -p tsconfig.jest.json",
30-
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
30+
"clean": "jest --clearCache --config '{}' || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
3131
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
3232
"test": "npm run test-unit && npm run test-integration && npm run test-sequential",
3333
"test-unit": "jest test/unit",

packages/proto-rpc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"build": "tsc -b",
2323
"build-browser": "webpack --mode=development --progress",
2424
"check": "./test-proto.sh && tsc -p tsconfig.jest.json",
25-
"clean": "jest --clearCache || true; rm -rf dist generated *.tsbuildinfo node_modules/.cache || true",
25+
"clean": "jest --clearCache --config '{}' || true; rm -rf dist generated *.tsbuildinfo node_modules/.cache || true",
2626
"eslint": "./test-proto.sh && eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
2727
"test": "./test-proto.sh && npm run test-unit && npm run test-integration",
2828
"test-browser": "./test-proto.sh && karma start karma.config.ts",

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"build-browser-development": "NODE_ENV=development webpack --mode=development --progress",
3838
"build-browser-production": "NODE_ENV=production webpack --mode=production --progress",
3939
"check": "tsc -p tsconfig.jest.json",
40-
"clean": "jest --clearCache || true; rm -rf dist src/generated *.tsbuildinfo node_modules/.cache || true",
40+
"clean": "jest --clearCache --config '{}' || true; rm -rf dist src/generated *.tsbuildinfo node_modules/.cache || true",
4141
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts,mts}'",
4242
"generate-protoc-code": "./proto.sh",
4343
"test": "npm run test-unit && npm run test-integration && npm run test-end-to-end",

packages/test-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"scripts": {
1919
"build": "tsc -b",
2020
"check": "tsc -p tsconfig.jest.json",
21-
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
21+
"clean": "jest --clearCache --config '{}' || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
2222
"test": "jest",
2323
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'"
2424
},

packages/trackerless-network/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"build-browser": "webpack --mode=development --progress",
2222
"prebuild": "./proto.sh",
2323
"check": "tsc -p tsconfig.jest.json",
24-
"clean": "jest --clearCache || true; rm -rf dist generated *.tsbuildinfo node_modules/.cache || true",
24+
"clean": "jest --clearCache --config '{}' || true; rm -rf dist generated *.tsbuildinfo node_modules/.cache || true",
2525
"coverage": "jest --coverage",
2626
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
2727
"test": "npm run test-unit && npm run test-integration && npm run test-end-to-end",

0 commit comments

Comments
 (0)