Skip to content

Commit 4af912d

Browse files
ci: simplify test scripts and separate coverage from test runs (#2566)
Co-authored-by: Eden Zimbelman <eden.zimbelman@salesforce.com>
1 parent a7a367d commit 4af912d

11 files changed

Lines changed: 30 additions & 29 deletions

File tree

.changeset/simple-tests-shine.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
---
3+
4+
ci: simplify test scripts and separate coverage from test runs

.github/workflows/ci-build.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
- main
77
pull_request:
88

9+
env:
10+
LATEST_SUPPORTED_NODE: "24.x"
11+
912
jobs:
1013
test:
1114
timeout-minutes: 6
@@ -63,16 +66,16 @@ jobs:
6366
- name: Lint
6467
run: npm run lint
6568
- name: Build docs
69+
if: matrix.node-version == env.LATEST_SUPPORTED_NODE
6670
run: npm run docs
67-
- name: Run tests (Node 18/20)
68-
if: matrix.node-version != '22.x' && matrix.node-version != '24.x'
69-
# Node 18 lacks --test-reporter; Node 20 has coverage bugs. Use simpler script.
70-
run: npm run test:node18 --workspaces --if-present
71-
- name: Run tests (Node 22+)
72-
if: matrix.node-version == '22.x' || matrix.node-version == '24.x'
71+
- name: Run tests
72+
if: matrix.node-version != env.LATEST_SUPPORTED_NODE
7373
run: npm test
74+
- name: Run test coverage
75+
if: matrix.node-version == env.LATEST_SUPPORTED_NODE
76+
run: npm run test:coverage
7477
- name: Upload code coverage
75-
if: matrix.node-version == '24.x' && matrix.os == 'ubuntu-latest'
78+
if: matrix.node-version == env.LATEST_SUPPORTED_NODE && matrix.os == 'ubuntu-latest'
7679
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
7780
with:
7881
fail_ci_if_error: true

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"lint": "npx @biomejs/biome check packages",
2525
"lint:fix": "npx @biomejs/biome check --write packages",
2626
"test": "npm test --workspaces --if-present",
27+
"test:coverage": "npm run test:coverage --workspaces --if-present",
2728
"version": "npm run changeset version && npm install && npm run docs"
2829
},
2930
"devDependencies": {

packages/cli-hooks/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@
3737
"scripts": {
3838
"build": "shx chmod +x src/*.js",
3939
"prelint": "tsc --noemit --module es2022 --maxNodeModuleJsDepth 0 --project ./jsconfig.json",
40-
"test": "npm run test:unit",
41-
"test:node18": "bash -c 'node --test --test-reporter=spec src/*.test.js'",
42-
"test:unit": "node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=lcov.info --test-reporter=junit --test-reporter-destination=test-results.xml --test src/*.test.js"
40+
"test": "bash -c 'node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=test-results.xml --test src/*.test.js'",
41+
"test:coverage": "node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=lcov.info --test-reporter=junit --test-reporter-destination=test-results.xml --test src/*.test.js"
4342
},
4443
"bin": {
4544
"slack-cli-check-update": "src/check-update.js",

packages/cli-test/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@
3232
"build:clean": "shx rm -rf ./dist",
3333
"docs": "npx typedoc --plugin typedoc-plugin-markdown",
3434
"prepack": "npm run build",
35-
"test": "npm run test:unit",
36-
"test:node18": "npm run build && cross-env SLACK_CLI_PATH=/doesnt/matter bash -O globstar -c 'node --test --test-reporter=spec --import tsx src/**/*.test.ts'",
37-
"test:unit": "npm run build && cross-env SLACK_CLI_PATH=/doesnt/matter node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=lcov.info --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/**/*.test.ts"
35+
"test": "npm run build && bash -c 'cross-env SLACK_CLI_PATH=/doesnt/matter node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/**/*.test.ts'",
36+
"test:coverage": "npm run build && cross-env SLACK_CLI_PATH=/doesnt/matter node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=lcov.info --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/**/*.test.ts"
3837
},
3938
"dependencies": {
4039
"tree-kill": "^1.2.2",

packages/logger/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@
3333
"build:clean": "shx rm -rf ./dist",
3434
"docs": "npx typedoc --plugin typedoc-plugin-markdown",
3535
"prepack": "npm run build",
36-
"test": "npm run test:unit",
37-
"test:node18": "npm run build && node --test --test-reporter=spec --import tsx --test src/index.test.ts",
38-
"test:unit": "npm run build && node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=lcov.info --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/index.test.ts"
36+
"test": "npm run build && node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/index.test.ts",
37+
"test:coverage": "npm run build && node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=lcov.info --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/index.test.ts"
3938
},
4039
"dependencies": {
4140
"@types/node": ">=18"

packages/oauth/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@
3535
"build:clean": "shx rm -rf ./dist",
3636
"docs": "npx typedoc --plugin typedoc-plugin-markdown",
3737
"prepack": "npm run build",
38-
"test": "npm run test:unit",
39-
"test:node18": "npm run build && bash -O globstar -c 'node --test --test-reporter=spec --import tsx src/**/*.test.ts'",
40-
"test:unit": "npm run build && node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=lcov.info --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/**/*.test.ts",
38+
"test": "npm run build && bash -c 'node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/**/*.test.ts'",
39+
"test:coverage": "npm run build && node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=lcov.info --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/**/*.test.ts",
4140
"watch": "npx nodemon --watch 'src' --ext 'ts' --exec npm run build"
4241
},
4342
"dependencies": {

packages/socket-mode/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
"docs": "npx typedoc --plugin typedoc-plugin-markdown",
4545
"prepack": "npm run build",
4646
"test": "npm run test:unit && npm run test:integration",
47-
"test:node18": "npm run build && bash -c 'node --test --test-reporter=spec --import tsx src/*.test.ts' && npm run test:integration",
47+
"test:coverage": "npm run build && node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=lcov.info --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/*.test.ts",
4848
"test:integration": "npm run build && node --import tsx --test test/integration.test.js",
49-
"test:unit": "npm run build && node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=lcov.info --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/*.test.ts",
49+
"test:unit": "npm run build && bash -c 'node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/*.test.ts'",
5050
"watch": "npx nodemon --watch 'src' --ext 'ts' --exec npm test"
5151
},
5252
"dependencies": {

packages/web-api/AGENTS.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ expectAssignable<Parameters<typeof web.chat.appendStream>>([
224224
## Testing
225225

226226
```bash
227-
npm test --workspace=packages/web-api # all tests
228-
npm run test:unit --workspace=packages/web-api # unit only
227+
npm test --workspace=packages/web-api # all tests
229228
npm run test:types --workspace=packages/web-api # tsd only
230229
```
231230

packages/web-api/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@
4040
"build:clean": "shx rm -rf ./dist",
4141
"docs": "npx typedoc --plugin typedoc-plugin-markdown",
4242
"prepack": "npm run build",
43-
"test": "npm run test:unit",
44-
"test:node18": "npm run build && bash -c 'node --test --test-reporter=spec --import tsx src/*.test.ts'",
43+
"test": "npm run build && bash -c 'node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/*.test.ts'",
44+
"test:coverage": "npm run build && node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=lcov.info --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/*.test.ts",
4545
"test:integration": "npm run build && node test/integration/commonjs-project/index.js && node test/integration/esm-project/index.mjs && npm run test:integration:ts",
4646
"test:integration:ts": "cd test/integration/ts-4.7-project && npm i && npm run build",
4747
"test:types": "tsd",
48-
"test:unit": "npm run build && node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=lcov.info --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/*.test.ts",
4948
"watch": "npx nodemon --watch 'src' --ext 'ts' --exec npm run build"
5049
},
5150
"dependencies": {

0 commit comments

Comments
 (0)