Skip to content

fix: make npm run test runnable and enforce it in CI - #85

Merged
dubadub merged 1 commit into
mainfrom
fix/test-suite-node-version
Aug 11, 2026
Merged

fix: make npm run test runnable and enforce it in CI#85
dubadub merged 1 commit into
mainfrom
fix/test-suite-node-version

Conversation

@dubadub

@dubadub dubadub commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #84. See this comment for the full trace — my original diagnosis in the issue body was wrong, and the corrected one is what this PR acts on.

Two independent blockers, neither a bug in the tests themselves.

1. Wrong Node version

CLAUDE.md documented Node.js ≥18.17.0, <21. The root package.json requires >=22, and CI uses 22 — so the contributor-facing docs pointed at exactly the versions where the suite cannot load.

On Node 20 a CommonJS spec that requires an ESM module (any browser spec reaching @theia/monaco-editor-core) takes the synchronous require(esm) loader, which ignores the hooks @theia/test-setup registers via register():

$ node --version && node node_modules/.bin/_mocha ... prompt-variable-contribution.spec.js
v20.19.1
 Exception during run: TypeError [ERR_UNKNOWN_FILE_EXTENSION] ... aria.css

$ /usr/local/bin/node --version && /usr/local/bin/node node_modules/.bin/_mocha ... prompt-variable-contribution.spec.js
v23.10.0
  11 passing (87ms)

Worse, mocha retries a failed import with require, so the spec is partially executed twice and the retry surfaces The configuration is already set. — burying the real error entirely.

Fix: correct the documented requirement, add .nvmrc (22), and fail fast in @theia/test-setup with the actual reason:

✖ ERROR: Error: Theia tests require Node.js >= 22, but this is Node 20.19.1. Run `nvm use` (see .nvmrc) and try again.

2. Spec-less packages abort the run

@theia/cooklang-account and @theia/cooklang-branding declared "test": "theiaext test" but contain no spec files. Mocha exits non-zero on No test files found, and test:theia runs --concurrency=1 under nx bail — so the run stopped there and skipped ~40 packages. Upstream only declares the script where specs exist; these two now match, and the "adding a new package" checklist in CLAUDE.md calls it out.

Result

$ npm run test:theia
 Lerna (powered by Nx)   Successfully ran target test for 40 projects

1936 tests passing, 0 failing.

Added as a Test step in pr.yml, which until now ran only compile and lint — which is why this went unnoticed. test:electron is deliberately excluded: it needs a display server and the packaged app, so wiring it up means xvfb and a different kind of flake budget.

Note for reviewers

This PR does not change any test or product code — only docs, .nvmrc, two package.json scripts, a Node version guard, and the CI step. The Test step is new and unproven on CI hardware; if it turns out slow or flaky there, the cheap fallback is to keep it but mark it non-blocking.

The test suite could not be run end to end. Two independent blockers,
neither of which was a bug in the tests themselves.

Wrong Node version. `CLAUDE.md` documented `Node.js >=18.17.0, <21`, but
the root `package.json` requires `>=22` and CI uses 22. On Node 20 a
CommonJS spec that requires an ESM module - any browser spec that reaches
`@theia/monaco-editor-core` - takes the synchronous `require(esm)` loader,
which ignores the hooks `@theia/test-setup` registers via `register()`.
The run dies on `ERR_UNKNOWN_FILE_EXTENSION ... aria.css`, and because
mocha retries a failed `import` with `require`, the spec is partially
executed twice and the retry reports the far more confusing
`The configuration is already set.` instead. Same tree on Node 23: the
whole `ai-core` suite passes.

So: correct the documented requirement, add `.nvmrc`, and fail fast in
`@theia/test-setup` with the actual reason when running on Node < 22.

Spec-less packages. `@theia/cooklang-account` and `@theia/cooklang-branding`
declared `"test": "theiaext test"` without having a single spec file. Mocha
exits non-zero on `No test files found`, and `test:theia` runs with
`--concurrency=1` under nx bail, so the run aborted there and skipped every
package after it. Upstream only declares the script where specs exist; do
the same, and note it in the "adding a new package" checklist.

`npm run test:theia` now passes: 40 projects, 1936 tests, 0 failing. Wire
it into `pr.yml`, which until now ran only compile and lint - which is why
this went unnoticed. `test:electron` is deliberately left out; it needs a
display server and the packaged app.

Fixes #84
@dubadub
dubadub merged commit 52788d2 into main Aug 11, 2026
2 checks passed
@dubadub
dubadub deleted the fix/test-suite-node-version branch August 11, 2026 12:39
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.

Tests: @theia/ai-core suite aborts at load time, taking the rest of npm run test with it

1 participant