Skip to content

Commit 7c88d26

Browse files
chore: update all test scripts to remove coverage flag (#10582)
* chore: add test-coverage script Adds a `test-coverage` script to each package. With this change, each package has these two scripts: - `test` - run tests with coverage disabled - `test-coverage` - run tests with coverage enabled (_if_ the package wants to support coverage) Before this change, `test` behaved like `test-coverage` (i.e. packages had coverage enabled in it). In CI, we then forced coverage off in some situations by passing a flag: `npm run test -- --coverage=false`. This resulted in commands like `jest --coverage --coverage=false`. While jest is happy with this, vitest is not. Given we are likely to move to vitest, it is worth fixing this ahead of time. * chore(ast-spec): enable test coverage * chore(scope-manager): add jest as dependency * chore: drop coverage script * chore: disable coverage in jest base config * review changes --------- Co-authored-by: Kirk Waiblinger <[email protected]>
1 parent c910ac1 commit 7c88d26

File tree

15 files changed

+15
-18
lines changed

15 files changed

+15
-18
lines changed

.github/workflows/ci.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,14 @@ jobs:
196196

197197
# collect coverage on the primary node version
198198
# we don't collect coverage on other node versions so they run faster
199-
# note that we don't do this as a single `run` with a flag because some
200-
# packages don't collect coverage on purpose, so forcing `--coverage=true`
201-
# would override the config
202199
- name: Run unit tests with coverage for ${{ matrix.package }}
203200
if: env.PRIMARY_NODE_VERSION == matrix.node-version && matrix.os == 'ubuntu-latest'
204-
run: npx nx test ${{ matrix.package }}
201+
run: npx nx run ${{ matrix.package }}:test -- --coverage
205202
env:
206203
CI: true
207204
- name: Run unit tests for ${{ matrix.package }}
208205
if: env.PRIMARY_NODE_VERSION != matrix.node-version || matrix.os != 'ubuntu-latest'
209-
run: npx nx test ${{ matrix.package }} --coverage=false
206+
run: npx nx test ${{ matrix.package }}
210207
env:
211208
CI: true
212209

jest.config.base.js

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const path = require('node:path');
66
// @ts-check
77
/** @type {import('@jest/types').Config.InitialOptions} */
88
module.exports = {
9-
collectCoverage: true,
109
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
1110
coverageReporters: ['lcov'],
1211
moduleFileExtensions: [

packages/ast-spec/jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const baseConfig = require('../../jest.config.base.js');
77
/** @type {import('@jest/types').Config.InitialOptions} */
88
module.exports = {
99
...baseConfig,
10-
collectCoverage: false,
1110
setupFilesAfterEnv: [
1211
...baseConfig.setupFilesAfterEnv,
1312
'./tests/util/setupJest.ts',
1413
],
14+
coveragePathIgnorePatterns: ['/fixtures/', '/node_modules/'],
1515
};

packages/eslint-plugin-internal/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"postclean": "rimraf dist && rimraf coverage",
2020
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
2121
"lint": "npx nx lint",
22-
"test": "jest --coverage",
22+
"test": "jest",
2323
"check-types": "npx nx typecheck"
2424
},
2525
"dependencies": {

packages/eslint-plugin/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"generate:breaking-changes": "tsx tools/generate-breaking-changes.mts",
5757
"generate:configs": "npx nx generate-configs repo",
5858
"lint": "npx nx lint",
59-
"test": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --coverage --logHeapUsage",
59+
"test": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --logHeapUsage",
6060
"test-single": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --no-coverage",
6161
"check-types": "npx nx typecheck"
6262
},

packages/integration-tests/jest.config.js

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const { tseslintPackages } = require('./tools/pack-packages');
88
/** @type {import('@jest/types').Config.InitialOptions} */
99
module.exports = {
1010
...require('../../jest.config.base.js'),
11-
collectCoverage: false,
1211
globals: {
1312
tseslintPackages,
1413
},

packages/parser/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"postclean": "rimraf dist && rimraf _ts4.3 && rimraf coverage",
4747
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
4848
"lint": "npx nx lint",
49-
"test": "jest --coverage",
49+
"test": "jest",
5050
"check-types": "npx nx typecheck"
5151
},
5252
"peerDependencies": {

packages/rule-tester/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"lint": "npx nx lint",
4545
"pretest-eslint-base": "tsc -b tsconfig.build.json",
4646
"test-eslint-base": "mocha --require source-map-support/register ./tests/eslint-base/eslint-base.test.js",
47-
"test": "npx jest --coverage",
47+
"test": "npx jest",
4848
"check-types": "npx nx typecheck"
4949
},
5050
"//": "NOTE - AJV is out-of-date, but it's intentionally synced with ESLint - https://github.com/eslint/eslint/blob/ad9dd6a933fd098a0d99c6a9aa059850535c23ee/package.json#L70",

packages/scope-manager/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
4444
"generate-lib": "npx nx generate-lib repo",
4545
"lint": "npx nx lint",
46-
"test": "npx nx test --code-coverage",
46+
"test": "jest",
4747
"check-types": "npx nx typecheck"
4848
},
4949
"dependencies": {
@@ -55,6 +55,7 @@
5555
"@types/glob": "*",
5656
"@typescript-eslint/typescript-estree": "8.25.0",
5757
"glob": "*",
58+
"jest": "29.7.0",
5859
"jest-specific-snapshot": "*",
5960
"make-dir": "*",
6061
"prettier": "^3.2.5",

packages/type-utils/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"postclean": "rimraf dist && rimraf _ts3.4 && rimraf _ts4.3 && rimraf coverage",
4444
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
4545
"lint": "npx nx lint",
46-
"test": "jest --coverage",
46+
"test": "jest",
4747
"check-types": "npx nx typecheck"
4848
},
4949
"dependencies": {

packages/typescript-eslint/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"postclean": "rimraf dist && rimraf _ts4.3 && rimraf coverage",
5050
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
5151
"lint": "nx lint",
52-
"test": "jest --coverage --passWithNoTests",
52+
"test": "jest --passWithNoTests",
5353
"check-types": "npx nx typecheck"
5454
},
5555
"dependencies": {

packages/typescript-estree/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"postclean": "rimraf dist && rimraf _ts4.3 && rimraf coverage",
5252
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
5353
"lint": "npx nx lint",
54-
"test": "jest --coverage --runInBand --verbose",
54+
"test": "jest --runInBand --verbose",
5555
"check-types": "npx nx typecheck"
5656
},
5757
"dependencies": {

packages/utils/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"postclean": "rimraf dist && rimraf _ts3.4 && rimraf _ts4.3 && rimraf coverage",
6161
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
6262
"lint": "npx nx lint",
63-
"test": "jest --coverage",
63+
"test": "jest",
6464
"check-types": "npx nx typecheck"
6565
},
6666
"dependencies": {

packages/visitor-keys/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"postclean": "rimraf dist && rimraf _ts3.4 && rimraf _ts4.3 && rimraf coverage",
4545
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
4646
"lint": "npx nx lint",
47-
"test": "jest --coverage",
47+
"test": "jest",
4848
"check-types": "npx nx typecheck"
4949
},
5050
"dependencies": {

yarn.lock

+1
Original file line numberDiff line numberDiff line change
@@ -5812,6 +5812,7 @@ __metadata:
58125812
"@typescript-eslint/typescript-estree": 8.25.0
58135813
"@typescript-eslint/visitor-keys": 8.25.0
58145814
glob: "*"
5815+
jest: 29.7.0
58155816
jest-specific-snapshot: "*"
58165817
make-dir: "*"
58175818
prettier: ^3.2.5

0 commit comments

Comments
 (0)