Skip to content

GLSP-1635: Migrate test framework from Mocha to Vitest#522

Merged
tortmayr merged 3 commits into
masterfrom
GLSP-1635-vitest-migration
Jun 23, 2026
Merged

GLSP-1635: Migrate test framework from Mocha to Vitest#522
tortmayr merged 3 commits into
masterfrom
GLSP-1635-vitest-migration

Conversation

@tortmayr

@tortmayr tortmayr commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What it does

Replaces the Mocha/Chai/nyc/Sinon test stack 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
  • Run the workflow-standalone example's TS scripts via Node's native type stripping instead of ts-node (which the Mocha toolchain used to provide transitively): convert the scripts to ESM (.mts), drop the ts-node dependency, and raise the Node engine floor to 22.18 where stripping is unflagged

Also:

  • Fix indentation in the local /fix skill doc

Part of: eclipse-glsp/glsp#1635

How to test

pnpm install
pnpm test
pnpm build
  • pnpm test type-checks the specs (compile:test) and runs the full suite under Vitest — 53 test files / 823 tests pass (~2.3s)
  • Spec type-checking is active: a deliberate type error in a spec fails pnpm compile:test
  • pnpm build succeeds with no ts-node installed (workspace or global) — the example's .mts scripts run under Node's native type stripping
  • pnpm test:coverage produces the merged coverage report

Follow-ups

None.

Changelog

  • This PR should be mentioned in the changelog
  • This PR introduces a breaking change (if yes, provide more details below for the changelog and the migration guide)

@tortmayr
tortmayr force-pushed the GLSP-1635-vitest-migration branch 2 times, most recently from 39c94cb to ba9d270 Compare June 22, 2026 22:48
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Preview: Removed (PR closed).

- 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
- Run the workflow-standalone example's TS scripts via Node's native type
  stripping instead of ts-node, which the Mocha toolchain used to provide
  transitively: convert the scripts to ESM (.mts), drop the ts-node
  dependency, and raise the Node engine floor to 22.18 where stripping is
  unflagged

Also:
- Fix indentation in the local /fix skill doc

Part of: eclipse-glsp/glsp#1635

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrate the monorepo’s test stack from Mocha/Chai/nyc/Sinon to Vitest, centralizing configuration and coverage, updating test sources to the Vitest API, and adjusting tooling/CI/scripts (including the workflow-standalone example) to run without ts-node.

Changes:

  • Introduce a single root Vitest/Vite config and new composite tsconfig.test.json projects wired through pnpm compile:test.
  • Update protocol/client specs to use Vitest assertions/mocks/timers and remove obsolete Mocha/nyc configs and helpers.
  • Update CI, VS Code launch configs, and workflow-standalone scripts to run under Node’s native TypeScript stripping (Node >= 22.18).

Reviewed changes

Copilot reviewed 77 out of 81 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vite.config.ts Adds a flat root Vitest/Vite config for monorepo-wide test/coverage behavior.
tsconfig.test.json Adds root composite TS project for type-checking tests across packages.
tsconfig.json Switches root TS config base away from the Mocha-specific preset.
tsconfig.eslint.json Ensures root Vitest config is included in ESLint TS project.
pnpm-workspace.yaml Updates hoisting patterns and override comments for the new test toolchain.
packages/protocol/tsconfig.test.json Adds protocol test-only composite TS config.
packages/protocol/tsconfig.json Excludes tests from protocol build outputs.
packages/protocol/src/utils/uuid.spec.ts Migrates UUID tests from Chai to Vitest.
packages/protocol/src/utils/test-util.ts Removes obsolete Mocha/Chai async-throw helper utilities.
packages/protocol/src/utils/geometry-vector.spec.ts Migrates vector tests from Chai to Vitest.
packages/protocol/src/utils/geometry-movement.spec.ts Migrates movement tests from Chai to Vitest.
packages/protocol/src/utils/function-util.spec.ts Migrates debounce tests from Sinon fake timers to Vitest timers/mocks.
packages/protocol/src/utils/event.spec.ts Migrates event tests from Sinon/Chai to Vitest.
packages/protocol/src/utils/disposable.spec.ts Migrates disposable tests from Sinon/Chai to Vitest spies/assertions.
packages/protocol/src/utils/array-util.spec.ts Migrates array util tests from Chai to Vitest.
packages/protocol/src/sprotty-geometry-point.spec.ts Migrates point tests from Chai to Vitest.
packages/protocol/src/sprotty-geometry-dimension.spec.ts Migrates dimension tests from Chai to Vitest.
packages/protocol/src/di/lazy-injector.spec.ts Migrates DI tests from Chai to Vitest.
packages/protocol/src/di/feature-module.spec.ts Migrates DI feature-module tests from Chai to Vitest.
packages/protocol/src/di/container-configuration.spec.ts Migrates container configuration tests from Chai to Vitest.
packages/protocol/src/action-protocol/viewport.spec.ts Migrates viewport action tests from Chai to Vitest.
packages/protocol/src/action-protocol/undo-redo.spec.ts Migrates undo/redo tests from Chai to Vitest.
packages/protocol/src/action-protocol/tool-palette.spec.ts Migrates tool palette tests from Chai to Vitest.
packages/protocol/src/action-protocol/node-modification.spec.ts Migrates node modification tests from Chai to Vitest.
packages/protocol/src/action-protocol/model-saving.spec.ts Migrates model saving tests from Chai to Vitest.
packages/protocol/src/action-protocol/model-layout.spec.ts Migrates model layout tests from Chai to Vitest.
packages/protocol/src/action-protocol/model-edit-mode.spec.ts Migrates edit mode tests from Chai to Vitest.
packages/protocol/src/action-protocol/model-data.spec.ts Migrates model data tests from Chai to Vitest and fixes nested it structure.
packages/protocol/src/action-protocol/element-validation.spec.ts Migrates validation tests from Chai to Vitest and fixes nested it structure.
packages/protocol/src/action-protocol/element-type-hints.spec.ts Migrates type-hints tests from Chai to Vitest.
packages/protocol/src/action-protocol/element-text-editing.spec.ts Migrates text-editing tests from Chai to Vitest.
packages/protocol/src/action-protocol/element-selection.spec.ts Migrates selection tests from Chai to Vitest.
packages/protocol/src/action-protocol/element-navigation.spec.ts Migrates navigation tests from Chai to Vitest.
packages/protocol/src/action-protocol/element-hover.spec.ts Migrates hover tests from Chai to Vitest.
packages/protocol/src/action-protocol/element-creation.spec.ts Migrates creation tests from Chai to Vitest.
packages/protocol/src/action-protocol/edge-modification.spec.ts Migrates edge modification tests from Chai to Vitest.
packages/protocol/src/action-protocol/contexts.spec.ts Migrates contexts tests from Chai to Vitest.
packages/protocol/src/action-protocol/clipboard.spec.ts Migrates clipboard tests from Chai to Vitest.
packages/protocol/src/action-protocol/client-notification.spec.ts Migrates client notification tests from Chai to Vitest.
packages/protocol/src/action-protocol/base-protocol.spec.ts Migrates base protocol tests from Chai to Vitest.
packages/protocol/package.json Removes Mocha/nyc scripts and excludes test assets from packed files.
packages/client/tsconfig.test.json Adds client test-only composite TS config.
packages/client/tsconfig.json Excludes tests from client build outputs.
packages/client/src/utils/gmodel-util.spec.ts Migrates gmodel util tests from Chai to Vitest.
packages/client/src/features/validation/marker-navigator.spec.ts Migrates marker navigator tests from Mocha/Chai to Vitest.
packages/client/src/features/tools/marquee-selection/marquee-behavior.spec.ts Migrates marquee behavior tests from Chai to Vitest.
packages/client/src/features/test/layouter-test-util.ts Removes Mocha dependency and fixes import path for layouter test util.
packages/client/src/features/routing/sticky-manhattan-edge-router.spec.ts Migrates routing tests from Chai to Vitest.
packages/client/src/features/navigation/navigation-target-resolver.spec.ts Migrates navigation resolver tests from Mocha/Chai to Vitest.
packages/client/src/features/layout/layout-elements-action.spec.ts Migrates layout tests to Vitest and removes Sinon usage.
packages/client/src/features/grid/grid-snapper.spec.ts Migrates grid snapper tests from Chai to Vitest.
packages/client/src/features/change-bounds/point-position-updater.spec.ts Migrates point position updater tests from Chai to Vitest.
packages/client/src/features/bounds/vbox-layout.spec.ts Migrates VBox layouter tests to Vitest and uses shared test util module.
packages/client/src/features/bounds/hbox-layout.spec.ts Migrates HBox layouter tests to Vitest and uses shared test util module.
packages/client/src/features/bounds/freeform-layout.spec.ts Migrates FreeForm layouter tests to Vitest and uses shared test util module.
packages/client/src/default-modules.spec.ts Migrates default-modules tests to Vitest and updates spying approach.
packages/client/src/base/selection-service.spec.ts Migrates selection service tests from Chai/Sinon to Vitest mocks/assertions.
packages/client/src/base/model/model-initialization-constraint.spec.ts Migrates model initialization constraint tests from Sinon/Chai to Vitest.
packages/client/src/base/model/glsp-model-source.ts Converts an import to type-only to avoid runtime coupling.
packages/client/src/base/feedback/feedback-emitter.spec.ts Migrates feedback emitter tests from Chai to Vitest.
packages/client/src/base/action-dispatcher.spec.ts Migrates action dispatcher tests from Chai to Vitest.
packages/client/package.json Removes Mocha/nyc scripts and excludes tests from packed files.
package.json Replaces test scripts with Vitest + compile:test, updates Node engine floor, and removes obsolete deps.
examples/workflow-standalone/scripts/start.mts Switches workflow-standalone scripts to .mts and updates imports for ESM/stripping.
examples/workflow-standalone/scripts/start-node-server.mts Switches workflow-standalone server launcher to .mts and updates imports.
examples/workflow-standalone/scripts/download-server.mts Updates download helper for ESM/JSON import attributes and non-require.main entry detection.
examples/workflow-standalone/package.json Updates scripts to run via node (no ts-node).
CLAUDE.md Updates documented test command(s) to Vitest.
AGENTS.md Updates documented test command(s) to Vitest.
.vscode/launch.json Replaces Mocha-based debug launchers with Vitest launchers.
.nycrc Removes obsolete nyc configuration.
.mocharc Removes obsolete Mocha configuration.
.gitignore Removes nyc/CTRF artifacts and broadens tsbuildinfo ignores.
.github/workflows/ci.yml Updates CI to run pnpm test/pnpm test:coverage under Vitest and drops CTRF reporting step.
.claude/skills/fix/SKILL.md Fixes indentation in the /fix skill documentation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/client/src/default-modules.spec.ts
- Add an afterEach to restore the spy created on container.load,
  since container.restore() only resets Inversify bindings and would
  otherwise leave the method permanently spied across tests

Part of: eclipse-glsp/glsp#1635

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 77 out of 81 changed files in this pull request and generated 1 comment.

Comment thread packages/protocol/src/action-protocol/edge-modification.spec.ts Outdated
- Rework the ChangeRoutingPointsOperation.create tests so they
  actually exercise that factory instead of ReconnectEdgeOperation,
  covering both the defaults and the optional-args cases

Part of: eclipse-glsp/glsp#1635
@tortmayr
tortmayr merged commit 8f5ca82 into master Jun 23, 2026
7 checks passed
@tortmayr
tortmayr deleted the GLSP-1635-vitest-migration branch June 23, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants