diff --git a/.changeset/simple-tests-shine.md b/.changeset/simple-tests-shine.md new file mode 100644 index 000000000..cfbc666e1 --- /dev/null +++ b/.changeset/simple-tests-shine.md @@ -0,0 +1,4 @@ +--- +--- + +ci: simplify test scripts and separate coverage from test runs diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 342a54a53..275aed6bf 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -6,6 +6,9 @@ on: - main pull_request: +env: + LATEST_SUPPORTED_NODE: "24.x" + jobs: test: timeout-minutes: 6 @@ -64,15 +67,14 @@ jobs: run: npm run lint - name: Build docs run: npm run docs - - name: Run tests (Node 18/20) - if: matrix.node-version != '22.x' && matrix.node-version != '24.x' - # Node 18 lacks --test-reporter; Node 20 has coverage bugs. Use simpler script. - run: npm run test:node18 --workspaces --if-present - - name: Run tests (Node 22+) - if: matrix.node-version == '22.x' || matrix.node-version == '24.x' + - name: Run tests + if: matrix.node-version != env.LATEST_SUPPORTED_NODE run: npm test + - name: Run test coverage + if: matrix.node-version == env.LATEST_SUPPORTED_NODE + run: npm run test:coverage - name: Upload code coverage - if: matrix.node-version == '24.x' && matrix.os == 'ubuntu-latest' + if: matrix.node-version == env.LATEST_SUPPORTED_NODE && matrix.os == 'ubuntu-latest' uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0 with: fail_ci_if_error: true diff --git a/package.json b/package.json index 7a62f1211..73aab5b7d 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "lint": "npx @biomejs/biome check packages", "lint:fix": "npx @biomejs/biome check --write packages", "test": "npm test --workspaces --if-present", + "test:coverage": "npm run test:coverage --workspaces --if-present", "version": "npm run changeset version && npm install && npm run docs" }, "devDependencies": { diff --git a/packages/cli-hooks/package.json b/packages/cli-hooks/package.json index 77cdfb43b..de198fe84 100644 --- a/packages/cli-hooks/package.json +++ b/packages/cli-hooks/package.json @@ -37,9 +37,8 @@ "scripts": { "build": "shx chmod +x src/*.js", "prelint": "tsc --noemit --module es2022 --maxNodeModuleJsDepth 0 --project ./jsconfig.json", - "test": "npm run test:unit", - "test:node18": "bash -c 'node --test --test-reporter=spec src/*.test.js'", - "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" + "test": "bash -c 'node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=test-results.xml --test src/*.test.js'", + "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" }, "bin": { "slack-cli-check-update": "src/check-update.js", diff --git a/packages/cli-test/package.json b/packages/cli-test/package.json index f580c4a3f..918898f79 100644 --- a/packages/cli-test/package.json +++ b/packages/cli-test/package.json @@ -32,9 +32,8 @@ "build:clean": "shx rm -rf ./dist", "docs": "npx typedoc --plugin typedoc-plugin-markdown", "prepack": "npm run build", - "test": "npm run test:unit", - "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'", - "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" + "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'", + "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" }, "dependencies": { "tree-kill": "^1.2.2", diff --git a/packages/logger/package.json b/packages/logger/package.json index d23e85875..de692522b 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -33,9 +33,8 @@ "build:clean": "shx rm -rf ./dist", "docs": "npx typedoc --plugin typedoc-plugin-markdown", "prepack": "npm run build", - "test": "npm run test:unit", - "test:node18": "npm run build && node --test --test-reporter=spec --import tsx --test src/index.test.ts", - "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" + "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", + "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" }, "dependencies": { "@types/node": ">=18" diff --git a/packages/oauth/package.json b/packages/oauth/package.json index a19d0a90a..b03ee1414 100644 --- a/packages/oauth/package.json +++ b/packages/oauth/package.json @@ -35,9 +35,8 @@ "build:clean": "shx rm -rf ./dist", "docs": "npx typedoc --plugin typedoc-plugin-markdown", "prepack": "npm run build", - "test": "npm run test:unit", - "test:node18": "npm run build && bash -O globstar -c 'node --test --test-reporter=spec --import tsx src/**/*.test.ts'", - "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", + "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'", + "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", "watch": "npx nodemon --watch 'src' --ext 'ts' --exec npm run build" }, "dependencies": { diff --git a/packages/socket-mode/package.json b/packages/socket-mode/package.json index 9f3f7b300..dd2ce97e2 100644 --- a/packages/socket-mode/package.json +++ b/packages/socket-mode/package.json @@ -44,9 +44,9 @@ "docs": "npx typedoc --plugin typedoc-plugin-markdown", "prepack": "npm run build", "test": "npm run test:unit && npm run test:integration", - "test:node18": "npm run build && bash -c 'node --test --test-reporter=spec --import tsx src/*.test.ts' && npm run test:integration", + "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", "test:integration": "npm run build && node --import tsx --test test/integration.test.js", - "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", + "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'", "watch": "npx nodemon --watch 'src' --ext 'ts' --exec npm test" }, "dependencies": { diff --git a/packages/web-api/AGENTS.md b/packages/web-api/AGENTS.md index d384a62aa..e40330374 100644 --- a/packages/web-api/AGENTS.md +++ b/packages/web-api/AGENTS.md @@ -225,7 +225,7 @@ expectAssignable>([ ```bash npm test --workspace=packages/web-api # all tests -npm run test:unit --workspace=packages/web-api # unit only +npm test --workspace=packages/web-api # unit only npm run test:types --workspace=packages/web-api # tsd only ``` diff --git a/packages/web-api/package.json b/packages/web-api/package.json index a616329b9..22a38cddc 100644 --- a/packages/web-api/package.json +++ b/packages/web-api/package.json @@ -40,12 +40,11 @@ "build:clean": "shx rm -rf ./dist", "docs": "npx typedoc --plugin typedoc-plugin-markdown", "prepack": "npm run build", - "test": "npm run test:unit", - "test:node18": "npm run build && bash -c 'node --test --test-reporter=spec --import tsx src/*.test.ts'", + "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'", + "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", "test:integration": "npm run build && node test/integration/commonjs-project/index.js && node test/integration/esm-project/index.mjs && npm run test:integration:ts", "test:integration:ts": "cd test/integration/ts-4.7-project && npm i && npm run build", "test:types": "tsd", - "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", "watch": "npx nodemon --watch 'src' --ext 'ts' --exec npm run build" }, "dependencies": { diff --git a/packages/webhook/package.json b/packages/webhook/package.json index 4a294b015..709cf3138 100644 --- a/packages/webhook/package.json +++ b/packages/webhook/package.json @@ -37,9 +37,8 @@ "build:clean": "shx rm -rf ./dist", "docs": "npx typedoc --plugin typedoc-plugin-markdown", "prepack": "npm run build", - "test": "npm run test:unit", - "test:node18": "npm run build && node --test --test-reporter=spec --import tsx --test src/IncomingWebhook.test.ts", - "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/IncomingWebhook.test.ts" + "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/IncomingWebhook.test.ts", + "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/IncomingWebhook.test.ts" }, "dependencies": { "@slack/types": "^2.20.1",