Skip to content

Commit f53fde5

Browse files
chore: remove mocha chai and c8
1 parent 80cf13f commit f53fde5

37 files changed

Lines changed: 263 additions & 60 deletions

.github/maintainers_guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ All you need to work with this project is a supported version of [Node.js](https
1515

1616
#### Unit Tests
1717

18-
This package has unit tests for most files in the same directory the code is in with the suffix `.spec` (i.e. `exampleFile.spec.ts`). You can run the entire test suite using the npm script `npm test`. This command is also executed by GitHub Actions, the continuous integration service, for every Pull Request and branch. The coverage is computed with the `codecov` package. The tests themselves are run using the `mocha` test runner.
18+
This package has unit tests for most files in the same directory the code is in with the suffix `.spec` (i.e. `exampleFile.spec.ts`). You can run the entire test suite using the npm script `npm test`. This command is also executed by GitHub Actions, the continuous integration service, for every Pull Request and branch. Coverage is collected with Node.js's built-in test coverage support and uploaded by CI. The tests themselves are run using Node.js's built-in test runner.
1919

2020
Test code should be written in syntax that runs on the oldest supported Node.js version. This ensures that backwards compatibility is tested and the APIs look reasonable in versions of Node.js that do not support the most modern syntax.
2121

2222
#### Debugging
2323

24-
A useful trick for debugging inside tests is to use the Chrome Debugging Protocol feature of Node.js to set breakpoints and interactively debug. In order to do this you must run mocha directly. This means that you should have already linted the source (`npm run lint`), manually. You then run the tests using the following command: `./node_modules/.bin/mocha test/{test-name}.js --debug-brk --inspect` (replace {test-name} with an actual test file).
24+
A useful trick for debugging inside tests is to use the Chrome Debugging Protocol feature of Node.js to set breakpoints and interactively debug. In order to do this you should have already linted the source (`npm run lint`), manually. You can then run a specific test file with Node.js's test runner, for example: `node --inspect-brk --require ts-node/register --require source-map-support/register --require ./test/unit/node-test-globals.cjs --test test/unit/{test-name}.spec.ts` (replace `{test-name}` with an actual test file path).
2525

2626
#### Local Development
2727

.vscode/launch.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,23 @@
88
"type": "node",
99
"request": "launch",
1010
"name": "Spec tests",
11-
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
11+
"runtimeExecutable": "node",
1212
"stopOnEntry": false,
13-
"args": ["--config", ".mocharc.json", "--no-timeouts", "src/*.spec.ts", "src/**/*.spec.ts"],
13+
"args": [
14+
"--inspect-brk",
15+
"--require",
16+
"ts-node/register",
17+
"--require",
18+
"source-map-support/register",
19+
"--require",
20+
"./test/unit/node-test-globals.cjs",
21+
"--test",
22+
"test/unit/**/*.spec.ts"
23+
],
1424
"cwd": "${workspaceFolder}",
15-
"runtimeExecutable": null,
1625
"env": {
1726
"NODE_ENV": "testing",
18-
"TS_NODE_PROJECT": "tsconfig.test.json"
27+
"TS_NODE_PROJECT": "tsconfig.json"
1928
},
2029
"skipFiles": ["<node_internals>/**"]
2130
}

AGENTS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ npm test # Full pipeline: build -> lint -> type tests -> unit test
3131
npm run build # Clean build (rm dist/ + tsc compilation)
3232
npm run lint # Biome check (formatting + linting)
3333
npm run lint:fix # Biome auto-fix
34-
npm run test:unit # Unit tests only (mocha)
35-
npm run test:coverage # Unit tests with coverage (c8)
34+
npm run test:unit # Unit tests only (Node.js test runner)
35+
npm run test:coverage # Unit tests with built-in Node.js coverage
3636
npm run test:types # Type definition tests (tsd)
3737
npm run watch # Watch mode for development (rebuilds on src/ changes)
3838
```
@@ -171,9 +171,9 @@ test/types/ # tsd type tests
171171
### Test Conventions
172172

173173
- **Test files** use `*.spec.ts` suffix
174-
- **Assertions** use chai (`expect`, `assert`)
174+
- **Assertions** use the local `test/unit/helpers/assert.ts` compatibility helper backed by Node.js `assert` and Sinon assertions
175175
- **Mocking** uses sinon (`stub`, `spy`, `fake`) and proxyquire for module-level dependency replacement
176-
- **Test config** in `test/unit/.mocharc.json`
176+
- **Test config** lives in `package.json` scripts plus `test/unit/node-test-globals.cjs`
177177
- **Where to put new tests:** Mirror the source structure. For `src/Foo.ts`, add `test/unit/Foo.spec.ts`. For `src/receivers/Bar.ts`, add `test/unit/receivers/Bar.spec.ts`.
178178

179179
### CI

package.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"lint": "npx @biomejs/biome check docs src test examples",
3333
"lint:fix": "npx @biomejs/biome check --write docs src test examples",
3434
"test": "npm run build && npm run lint && npm run test:types && npm run test:coverage",
35-
"test:unit": "TS_NODE_PROJECT=tsconfig.json mocha --config test/unit/.mocharc.json",
36-
"test:coverage": "c8 npm run test:unit",
35+
"test:unit": "TS_NODE_PROJECT=tsconfig.test.json TS_NODE_FILES=true node --require ts-node/register --require source-map-support/register --require ./test/unit/node-test-globals.cjs --test test/unit/**/*.spec.ts",
36+
"test:coverage": "TS_NODE_PROJECT=tsconfig.test.json TS_NODE_FILES=true node --experimental-test-coverage --require ts-node/register --require source-map-support/register --require ./test/unit/node-test-globals.cjs --test test/unit/**/*.spec.ts",
3737
"test:types": "tsd --files test/types",
3838
"watch": "npx nodemon --watch 'src' --ext 'ts' --exec npm run build"
3939
},
@@ -61,15 +61,10 @@
6161
"@biomejs/biome": "^1.9.0",
6262
"@changesets/cli": "^2.29.8",
6363
"@tsconfig/node18": "^18.2.4",
64-
"@types/chai": "^4.1.7",
65-
"@types/mocha": "^10.0.1",
6664
"@types/node": "18.19.130",
6765
"@types/proxyquire": "^1.3.31",
6866
"@types/sinon": "^17.0.4",
6967
"@types/tsscmp": "^1.0.0",
70-
"c8": "^10.1.2",
71-
"chai": "~4.3.0",
72-
"mocha": "^10.2.0",
7368
"proxyquire": "^2.1.3",
7469
"shx": "^0.3.2",
7570
"sinon": "^20.0.0",

test/unit/App/basic.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LogLevel } from '@slack/logger';
2-
import { assert } from 'chai';
2+
import { assert } from '../helpers/assert';
33
import sinon from 'sinon';
44
import { ErrorCode } from '../../../src/errors';
55
import SocketModeReceiver from '../../../src/receivers/SocketModeReceiver';

test/unit/App/middlewares/arguments.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { WebClient } from '@slack/web-api';
2-
import { assert } from 'chai';
2+
import { assert } from '../../helpers/assert';
33
import sinon, { type SinonSpy } from 'sinon';
44
import { LogLevel } from '../../../../src/App';
55
import type { SayStreamFn } from '../../../../src/context/create-say-stream';

test/unit/App/middlewares/global.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { WebClient } from '@slack/web-api';
2-
import { assert } from 'chai';
2+
import { assert } from '../../helpers/assert';
33
import sinon, { type SinonSpy } from 'sinon';
44
import type App from '../../../../src/App';
55
import type { ExtendedErrorHandlerArgs } from '../../../../src/App';

test/unit/App/middlewares/listener.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assert } from 'chai';
1+
import { assert } from '../../helpers/assert';
22
import sinon, { type SinonSpy } from 'sinon';
33
import type App from '../../../../src/App';
44
import { ErrorCode, isCodedError } from '../../../../src/errors';

test/unit/App/routing-action.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assert } from 'chai';
1+
import { assert } from '../helpers/assert';
22
import sinon, { type SinonSpy } from 'sinon';
33
import type App from '../../../src/App';
44
import {

test/unit/App/routing-function.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assert } from 'chai';
1+
import { assert } from '../helpers/assert';
22
import sinon from 'sinon';
33
import type App from '../../../src/App';
44
import {

0 commit comments

Comments
 (0)