Skip to content

Migrate tests to @vscode/test-cli - #29

Merged
dduugg merged 1 commit into
mainfrom
migrate-to-vscode-test-cli
Sep 30, 2026
Merged

dduugg merged 1 commit into
mainfrom
migrate-to-vscode-test-cli

Conversation

@dduugg

@dduugg dduugg commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #27. Replaces the hand-written mocha harness with @vscode/test-cli, the official VS Code extension test runner.

Changes

  • Harness: removes test/index.ts and test/runTests.ts. yarn test now runs vscode-test, configured in .vscode-test.mjs. test-cli defaults mocha to the tdd UI, so the config keeps the bdd UI and color output the old harness set.
  • Test discovery: renames test/packwerk.ts to test/packwerk.test.ts so the out/test/**/*.test.js glob picks it up. The old harness loaded every compiled file in out/test, so this test ran before and still runs.
  • @vscode/test-electron 2.5.2 → 3.1.0: 3.x finds the macOS executable that VS Code 1.110+ renamed from Electron to Code. yarn test failed locally on macOS with spawn … ENOENT and now works.
  • mocha: drops the direct mocha dev dependency, since test-cli brings its own (mocha 11). The serialize-javascript resolution from Resolve Dependabot alerts and add npm to Dependabot config #27 is still needed, because mocha 11 pins ^6.0.2.
  • Editor tooling: removes the "Launch Tests" debug configuration, which pointed at the deleted harness. .vscode/extensions.json recommends the Extension Test Runner for running and debugging tests from the Testing view, and vsc-extension-quickstart.md now describes that.
  • Packaging: adds .vscode-test.mjs to .vscodeignore. vsce ls confirms it's excluded.

Testing

  • yarn install --frozen-lockfile, yarn lint, and yarn run vscode:prepublish pass.
  • yarn test passes all 13 tests locally on macOS, with no workaround needed.
  • With one assertion deliberately broken, yarn test reported 1 failing and exited 1, so CI will still fail on test failures.

yarn audit reports one low-severity advisory in diff 7.0.0 (GHSA-73rr-hh4g-fpgx). It's already on main via sinon, and Dependabot auto-dismissed it (#40). mocha 11 now uses that same copy.

Replace the hand-written mocha harness (test/index.ts and
test/runTests.ts) with @vscode/test-cli, configured in .vscode-test.mjs.
test-cli defaults mocha to the tdd UI, so the config keeps the bdd UI
and color output the old harness set.

Rename test/packwerk.ts to packwerk.test.ts so the *.test.js glob picks
it up; the old harness loaded every compiled file in out/test.

Upgrade @vscode/test-electron to 3.x, which finds the macOS executable
that VS Code 1.110+ renamed from Electron to Code. 2.5.2 failed to launch
it with spawn ENOENT, so yarn test now works locally on macOS again.

Drop the direct mocha dependency, since test-cli brings its own. The
"Launch Tests" debug configuration pointed at the removed harness, so
recommend the Extension Test Runner extension for running and debugging
tests in the editor instead.
@dduugg
dduugg requested a review from a team as a code owner September 30, 2026 17:52
@github-project-automation github-project-automation Bot moved this to Triage in Modularity Sep 30, 2026
@dduugg
dduugg merged commit a3694d1 into main Sep 30, 2026
7 checks passed
@dduugg
dduugg deleted the migrate-to-vscode-test-cli branch September 30, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant