Skip to content

Commit ba9d270

Browse files
committed
GLSP-1635: Migrate test framework from Mocha to Vitest
- Replace the Mocha/Chai/nyc/Sinon setup with Vitest: consume the @eclipse-glsp/dev next packages, drop .mocharc/.nycrc, and point all test scripts at `vitest run` - Drive the whole monorepo from a single flat Vitest config at the repo root instead of per-package configs, yielding one merged coverage report - Type-check specs separately via composite tsconfig.test.json projects, since Vitest only transpiles; wire them through a `compile:test` step so `pnpm test` type-checks specs before running them - Import the test API explicitly in every spec (no ambient globals) and load reflect-metadata once via root setup files for the DI specs - Replace the custom expectToThrowAsync helper with Vitest's native rejects.toThrow() / toThrow() matchers and drop the obsolete test-util module - Keep test-only code out of the published packages by excluding specs and test/ helper directories from both the build and the packed files - Switch CI and contributor docs to Vitest: run `pnpm test`, and remove the now-obsolete test-report step and the redundant per-package and :ci test scripts - Clean up leftover tooling artifacts: ignore *.tsbuildinfo so the new per-config build-info is covered, and drop the obsolete nyc/CTRF ignores and clean targets - Declare ts-node directly in the workflow-standalone example, which previously relied on it being public-hoisted via the removed Mocha/ts-node toolchain Also: - Fix indentation in the local /fix skill doc Part of: eclipse-glsp/glsp#1635
1 parent 8b3a748 commit ba9d270

78 files changed

Lines changed: 2412 additions & 2724 deletions

File tree

Some content is hidden

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

.claude/skills/fix/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ description: Run the fix-and-verify suite for the workspace (compile, auto-fix l
55

66
Run the auto-fix and validation suite for the GLSP Client monorepo from the repository root.
77

8-
1. Build first. This is a hard gate: if the build fails, stop immediately, report the build errors, and do not run any of the following steps.
9-
The build must pass before anything else runs.
8+
1. Build first. This is a hard gate: if the build fails, stop immediately, report the build errors, and do not run any of the following steps.
9+
The build must pass before anything else runs.
1010

1111
```bash
1212
pnpm build

.github/workflows/ci.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,7 @@ jobs:
4444
node-version: 22.x
4545
cache: pnpm
4646
- name: Test
47-
run: pnpm test:ci
48-
- name: Publish Test Report
49-
uses: ctrf-io/github-test-reporter@0f299074936c32ccaab5be5230511f6b2b9080aa # v1.0.28
50-
with:
51-
report-path: 'packages/*/ctrf/*.json'
52-
summary-report: true
53-
file-report: true
54-
if: always()
47+
run: pnpm test
5548
lint:
5649
name: Lint
5750
timeout-minutes: 60
@@ -83,7 +76,7 @@ jobs:
8376
node-version: 22.x
8477
cache: pnpm
8578
- name: Run Coverage Tests
86-
run: pnpm test:coverage:ci
79+
run: pnpm test:coverage
8780
- name: Upload Coverage Report
8881
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
8982
with:

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.idea/
2-
.nyc_output/
32
coverage
43

54
node_modules/
@@ -16,10 +15,9 @@ examples/workflow-standalone/app/*
1615
*.jar
1716

1817
!packages/client/src/lib
19-
tsconfig.tsbuildinfo
18+
*.tsbuildinfo
2019
eslint.xml
2120
report.xml
22-
**/ctrf
2321
examples/workflow-standalone/server
2422

2523
.claude/local.settings.json

.mocharc

Lines changed: 0 additions & 11 deletions
This file was deleted.

.nycrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.vscode/launch.json

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,35 @@
55
"type": "node",
66
"request": "launch",
77
"name": "Run current test",
8-
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
9-
"args": ["--config", "${workspaceRoot}/.mocharc", "--timeout", "0", "${file}"],
8+
"autoAttachChildProcesses": true,
9+
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
10+
"program": "${workspaceFolder}/node_modules/vitest/vitest.mjs",
11+
"args": ["run", "${relativeFile}"],
12+
"smartStep": true,
1013
"console": "integratedTerminal",
11-
"internalConsoleOptions": "neverOpen",
12-
"env": {
13-
"TS_NODE_PROJECT": "${workspaceFolder}/tsconfig.json"
14-
}
14+
"internalConsoleOptions": "neverOpen"
1515
},
1616
{
1717
"type": "node",
1818
"request": "launch",
1919
"name": "Run tests",
20-
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
21-
"args": [
22-
"--config",
23-
"${workspaceRoot}/.mocharc",
24-
"--timeout",
25-
"0",
26-
"${workspaceFolder}/packages/client/src/**/*.spec.ts"
27-
],
28-
"env": {
29-
"TS_NODE_PROJECT": "${workspaceFolder}/tsconfig.json"
30-
},
20+
"autoAttachChildProcesses": true,
21+
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
22+
"program": "${workspaceFolder}/node_modules/vitest/vitest.mjs",
23+
"args": ["run", "packages/client/src"],
24+
"smartStep": true,
3125
"console": "integratedTerminal",
3226
"internalConsoleOptions": "neverOpen"
3327
},
3428
{
3529
"type": "node",
3630
"request": "launch",
3731
"name": "Run tests (protocol)",
38-
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
39-
"args": [
40-
"--config",
41-
"${workspaceRoot}/.mocharc",
42-
"--timeout",
43-
"0",
44-
"${workspaceFolder}/packages/protocol/src/**/*.spec.ts"
45-
],
46-
"env": {
47-
"TS_NODE_PROJECT": "${workspaceFolder}/tsconfig.json"
48-
},
32+
"autoAttachChildProcesses": true,
33+
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
34+
"program": "${workspaceFolder}/node_modules/vitest/vitest.mjs",
35+
"args": ["run", "packages/protocol/src"],
36+
"smartStep": true,
4937
"console": "integratedTerminal",
5038
"internalConsoleOptions": "neverOpen"
5139
}

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Eclipse GLSP Client monorepo. Provides the sprotty-based client framework for th
1414

1515
## Validation
1616

17-
- **Tests**: `pnpm test` (Mocha), single test: `pnpm test --grep 'test name'`
17+
- **Tests**: `pnpm test` (Vitest), single test: `pnpm test -t 'test name'`
1818

1919
## Inter-Package Import Rules
2020

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Eclipse GLSP Client monorepo. Provides the sprotty-based client framework for th
1212

1313
## Validation
1414

15-
- **Tests**: `pnpm test` (Mocha), single test: `pnpm test --grep 'test name'`
15+
- **Tests**: `pnpm test` (Vitest), single test: `pnpm test -t 'test name'`
1616
- After completing any code changes, always run the `/fix` skill before reporting completion. It auto-fixes lint/format/header issues and runs the tests; manually resolve anything it could not auto-fix (remaining lint errors, test failures) and re-run it.
1717

1818
## Commenting Style

examples/workflow-standalone/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747
"@types/tar": "6.1.5",
4848
"esbuild": "^0.28.1",
4949
"inversify": "^6.1.3",
50-
"tar": "7.5.16"
50+
"tar": "7.5.16",
51+
"ts-node": "^10.9.2",
52+
"typescript": "^5.9.2"
5153
},
5254
"publishConfig": {
5355
"access": "public"

package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
"bundle": "pnpm standalone bundle",
88
"bundle:browser": "pnpm standalone bundle:browser",
99
"check:all": "pnpm build && pnpm lint && pnpm format:check && pnpm headers:check && pnpm test",
10-
"clean": "pnpm -r run clean && rimraf coverage .nyc_output",
10+
"clean": "pnpm -r run clean && rimraf coverage *.tsbuildinfo",
1111
"compile": "tsc -b",
12+
"compile:test": "pnpm compile && tsc -b tsconfig.test.json",
1213
"dev": "pnpm standalone dev",
1314
"dev:browser": "pnpm standalone dev:browser",
1415
"dev:mcp": "pnpm standalone dev:mcp",
@@ -29,18 +30,15 @@
2930
"start:browser": "pnpm standalone start:browser",
3031
"start:exampleServer": "pnpm standalone start:server",
3132
"start:mcp": "pnpm standalone start:mcp",
32-
"test": "pnpm compile && pnpm -r --no-bail test",
33-
"test:ci": "pnpm compile && pnpm -r --no-bail test:ci",
34-
"test:coverage": "pnpm compile && pnpm -r test:coverage",
35-
"test:coverage:ci": "glsp coverageReport",
33+
"test": "pnpm compile:test && vitest run",
34+
"test:coverage": "pnpm compile:test && vitest run --coverage",
3635
"upgrade:next": "glsp updateNext"
3736
},
3837
"devDependencies": {
3938
"@eclipse-glsp/dev": "next",
4039
"@types/node": "22.x",
4140
"concurrently": "^9.2.1",
42-
"mocha-ctrf-json-reporter": "^0.0.9",
43-
"tsconfig-paths": "^4.2.0",
41+
"reflect-metadata": "^0.2.2",
4442
"typescript": "^5.9.2"
4543
},
4644
"packageManager": "pnpm@11.7.0",

0 commit comments

Comments
 (0)