Skip to content

Commit dbd38e2

Browse files
zimegClaude
andauthored
build: use node test runner for workspace packages (#2529)
Co-authored-by: Claude <svc-devxp-claude@slack-corp.com>
1 parent 57f4f22 commit dbd38e2

File tree

92 files changed

+724
-843
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+724
-843
lines changed

.changeset/chatty-tires-invite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@slack/oauth": patch
3+
---
4+
5+
fix: write files to the file installation store using the path.join method

.claude/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"Bash(git show:*)",
1818
"Bash(git status:*)",
1919
"Bash(grep:*)",
20+
"Bash(head:*)",
2021
"Bash(ls:*)",
2122
"Bash(node --version:*)",
2223
"Bash(npm --version:*)",
@@ -27,6 +28,7 @@
2728
"Bash(npm run lint:*)",
2829
"Bash(npm run lint:fix:*)",
2930
"Bash(npm test:*)",
31+
"Bash(tail:*)",
3032
"Bash(tree:*)",
3133
"WebFetch(domain:docs.slack.dev)",
3234
"WebFetch(domain:github.com)",

.github/maintainers_guide.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ The Node SDK is made up of multiple, individual packages, each with their own te
1515
```sh
1616
npm install
1717
npm run lint
18+
npm test
1819
npm test --workspace packages/web-api
1920
```
2021

21-
This project has tests for individual packages as `*.spec.js` files and inside of each package's `src` directory. Also, for verifying the behavior with the real Slack server-side and developer experience with installed packages, you can run the tests amd scripts under `prod-server-integration-tests`. Refer to the README file in the directory for details. These tests are supposed to be run in the project maintainers' manual execution. They are not part of CI builds for now.
22+
This project has tests for individual packages as `*.test.ts` (or `*.test.js`) files inside of each package's `src` directory. Tests use `node:test` as the test runner and `node:assert/strict` for assertions. Also, for verifying the behavior with the real Slack server-side and developer experience with installed packages, you can run the tests and scripts under `prod-server-integration-tests`. Refer to the README file in the directory for details. These tests are supposed to be run in the project maintainers' manual execution. They are not part of CI builds for now.
2223

2324
Upon opening a PR, tests are executed by GitHub Actions, our continuous integration system. GitHub Actions runs several, more granular builds in order to report on success and failure in a more targeted way.
2425

.github/workflows/ci-build.yml

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,17 @@ on:
88

99
jobs:
1010
test:
11-
timeout-minutes: 4
11+
timeout-minutes: 6
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
os: [ubuntu-latest, windows-latest]
16-
node-version: [18.x, 20.x, 22.x]
17-
package:
18-
- cli-hooks
19-
- cli-test
20-
- logger
21-
- oauth
22-
- rtm-api
23-
- socket-mode
24-
- types
25-
- web-api
26-
- webhook
15+
os:
16+
- "ubuntu-latest"
17+
- "windows-latest"
18+
node-version:
19+
- "18.x"
20+
- "20.x"
21+
- "22.x"
2722
runs-on: ${{ matrix.os }}
2823
permissions:
2924
contents: read
@@ -40,10 +35,12 @@ jobs:
4035
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
4136
with:
4237
node-version: ${{ matrix.node-version }}
43-
- run: npm --version
44-
- name: Install dependencies
38+
- name: Check versions
4539
run: |
46-
npm install --verbose
40+
node --version
41+
npm --version
42+
- name: Install dependencies
43+
run: npm install --verbose
4744
- name: Build packages
4845
run: |
4946
# Build packages without internal dependencies
@@ -62,32 +59,34 @@ jobs:
6259
npm run build --workspace=@slack/oauth
6360
npm run build --workspace=@slack/rtm-api
6461
npm run build --workspace=@slack/socket-mode
65-
- name: Run tests
66-
run: |
67-
npm run lint
68-
npm test --workspace=@slack/${{ matrix.package }}
69-
- name: Check for coverage report existence
70-
id: check_coverage
71-
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
72-
with:
73-
files: packages/${{ matrix.package }}/coverage/lcov.info
62+
- name: Lint
63+
run: npm run lint
64+
- name: Run tests (Node 18/20)
65+
if: matrix.node-version != '22.x'
66+
shell: bash
67+
# Node 18 lacks --test-reporter; Node 20 has coverage bugs. Use simpler script.
68+
run: npm run test:node18 --workspaces --if-present
69+
- name: Run tests (Node 22)
70+
if: matrix.node-version == '22.x'
71+
shell: bash
72+
run: npm test
7473
- name: Upload code coverage
75-
if: matrix.node-version == '22.x' && matrix.os == 'ubuntu-latest' && steps.check_coverage.outputs.files_exists == 'true'
74+
if: matrix.node-version == '22.x' && matrix.os == 'ubuntu-latest'
7675
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
7776
with:
78-
directory: packages/${{ matrix.package }}/coverage
7977
fail_ci_if_error: true
80-
flags: ${{ matrix.package }}
78+
files: packages/*/lcov.info
79+
flags: cli-hooks,cli-test,logger,oauth,socket-mode,web-api,webhook
8180
report_type: coverage
8281
token: ${{ secrets.CODECOV_TOKEN }}
8382
verbose: true
84-
- name: Upload test results to Codecov
83+
- name: Upload test results
8584
if: ${{ !cancelled() }}
8685
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
8786
with:
8887
fail_ci_if_error: true
89-
files: packages/${{ matrix.package }}/coverage/test-results.xml
90-
flags: ${{ matrix.node-version }},${{ matrix.os }},${{ matrix.package }}
88+
files: packages/cli-hooks/test-results.xml,packages/cli-test/test-results.xml,packages/logger/test-results.xml,packages/oauth/test-results.xml,packages/socket-mode/test-results.xml,packages/web-api/test-results.xml,packages/webhook/test-results.xml
89+
flags: ${{ matrix.node-version }},${{ matrix.os }}
9190
report_type: test_results
9291
token: ${{ secrets.CODECOV_TOKEN }}
9392
verbose: true

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ scripts/package-lock.json
44
examples/*/package-lock.json
55

66
npm-debug.log
7-
lerna-debug.log
7+
lcov.info
8+
test-results.xml
89
tmp/
910
.env*
1011

@@ -13,4 +14,3 @@ tmp/
1314
*.bk
1415

1516
.DS_Store
16-
.nyc_output/

AGENTS.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ npm run build --workspace=@slack/socket-mode
8383
## Code Conventions
8484

8585
- **Formatting**: configured in `biome.json`
86-
- **Test files**: `*.spec.ts` using Mocha + chai + sinon; coverage via c8
86+
- **Test files**: `*.test.{ts,js}` using `node:test` + `node:assert/strict`; coverage via `--experimental-test-coverage`
8787
- **Type tests**: `*.test-d.ts` using tsd
8888
- **Naming conventions for request/response types**:
8989
- Request: `{Namespace}{Action}Arguments` (e.g., `ChatPostMessageArguments`)
@@ -277,10 +277,14 @@ Entry point for response type generation. It:
277277

278278
## Testing
279279

280-
- **Unit tests**: Mocha + chai + sinon (`*.spec.ts` files), coverage via c8
280+
- **Test framework**: `node:test` (built-in) with `node:assert/strict` for assertions
281+
- **Test runner**: `node --experimental-test-coverage --import tsx --test`
282+
- **Unit tests**: `*.test.{ts,js}` files alongside source (e.g., `src/WebClient.test.ts`)
281283
- **Type tests**: tsd (`*.test-d.ts` files in `packages/web-api/test/types/`)
282284
- **Integration tests**: CommonJS, ESM, and TypeScript compatibility checks
283-
- **CI matrix**: Node 18.x, 20.x, 22.x on Ubuntu + Windows
285+
- **CI matrix**: Node 18.x, 20.x, 22.x on Ubuntu + Windows (6 jobs total)
286+
- **Coverage output**: `lcov.info` at each package root (not in `coverage/` dir)
287+
- **Test results**: `test-results.xml` at each package root (JUnit format)
284288

285289
Per-package test commands:
286290

codecov.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ flags:
66
paths:
77
- packages/cli-hooks/**
88
carryforward: true
9+
cli-test:
10+
paths:
11+
- packages/cli-test/**
12+
carryforward: true
913
logger:
1014
paths:
1115
- packages/logger/**

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"scripts": {
2222
"changeset": "npx @changesets/cli",
2323
"lint": "npx @biomejs/biome check packages",
24-
"lint:fix": "npx @biomejs/biome check --write packages"
24+
"lint:fix": "npx @biomejs/biome check --write packages",
25+
"test": "npm test --workspaces --if-present"
2526
},
2627
"devDependencies": {
2728
"@biomejs/biome": "^2.0.5",

packages/cli-hooks/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
# Node and NPM stuff
22
/node_modules
33
package-lock.json
4-
5-
# Coverage carryover
6-
/coverage

packages/cli-hooks/package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@
3636
},
3737
"scripts": {
3838
"build": "shx chmod +x src/*.js",
39-
"prebuild": "shx rm -rf ./coverage",
4039
"prelint": "tsc --noemit --module es2022 --maxNodeModuleJsDepth 0 --project ./jsconfig.json",
41-
"test": "c8 --config ./test/.c8rc.json mocha --config ./test/.mocharc.json src/*.spec.js"
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"
4243
},
4344
"bin": {
4445
"slack-cli-check-update": "src/check-update.js",
@@ -53,14 +54,9 @@
5354
},
5455
"devDependencies": {
5556
"@types/minimist": "^1.2.5",
56-
"@types/mocha": "^10.0.6",
5757
"@types/node": "^25.0.3",
5858
"@types/semver": "^7.5.6",
5959
"@types/sinon": "^21.0.0",
60-
"c8": "^10.1.2",
61-
"mocha": "^11.0.1",
62-
"mocha-junit-reporter": "^2.2.1",
63-
"mocha-multi-reporters": "^1.5.1",
6460
"shx": "^0.4.0",
6561
"sinon": "^21.0.0",
6662
"typescript": "5.9.3"

0 commit comments

Comments
 (0)