The Clarion extension has two types of tests:
- Location:
server/src/test/**/*.test.ts - Run without VS Code Extension Host
- Can be run via Mocha Test Explorer
- Config:
.mocharc.json(default)
- Location:
client/src/test/**/*.test.ts - REQUIRE VS Code Extension Host to run
- Cannot be run via Mocha Test Explorer (need VS Code API)
- Config:
.mocharc-client.json
# Run server tests only (default for Mocha Test Explorer)
npm run test:server
# Run client tests (requires VS Code Extension Host)
npm run test:client
# Run both server and client tests
npm run test:all
# Quick default test (server only)
npm testThe Mocha Test Explorer by Holger Benl will automatically discover server tests using .mocharc.json.
Important: The test explorer can only run server tests because client tests require the VS Code API which is not available in the test explorer context.
- Install: Mocha Test Adapter by Holger Benl
- The extension will read
.mocharc.jsonautomatically - Workspace Settings:
.vscode/settings.jsonshould contain:{ "mochaExplorer.files": [ "out/server/src/test/**/*.test.js" ], "mochaExplorer.watch": [ "out/server/src/**/*.js" ] } - Only server tests will appear in the test explorer UI
-
.mocharc.json- Main config (server tests only){ "ui": "tdd", "timeout": 30000, "spec": ["out/server/src/test/**/*.test.js"] } -
.mocharc-client.json- Client tests (used by npm script){ "ui": "tdd", "timeout": 30000, "spec": ["out/client/src/test/**/*.test.js"], "exclude": [ "out/client/src/test/UnreachableCodeDecorator.test.js", "out/client/src/test/TextEditingCommands.test.js" ] }
Client tests import the vscode module which is only available when running inside VS Code's Extension Host:
import * as vscode from 'vscode'; // Only works in Extension Host!Server tests run in pure Node.js and don't need VS Code:
import { ClarionTokenizer } from '../ClarionTokenizer'; // Pure Node.jsAs of 2026-01-05:
- Server tests: 439 passing, 33 failing (pre-existing)
- Includes 11 semantic token tests (all passing)
- Client tests: Run via Extension Host only
This means the Mocha Test Explorer is trying to load client tests. Solution:
- Verify
.mocharc.jsononly includes server tests - Check
.vscode/settings.json- ensuremochaExplorer.filesonly includes server tests:{ "mochaExplorer.files": [ "out/server/src/test/**/*.test.js" ] } - Reload VS Code window
- Refresh test explorer
Client tests must be run via:
- VS Code's Extension Host (F5 → Run Tests)
npm run test:client(if Extension Host is available)
They cannot be run via Mocha Test Explorer.
The semantic token implementation includes comprehensive tests:
server/src/test/StructureParentRelationship.test.ts- Tests: GROUP, VIEW, QUEUE, WINDOW, nested SHEET/TAB, line continuations
server/src/test/SemanticTokensPeriod.test.ts- Tests: Period terminators inherit parent structure colors
All 11 semantic token tests are passing ✅