Skip to content

fix(cli): recommend a DOM-capable runner for trace exports - #1768

Open
bfs2021 wants to merge 1 commit into
Avenx-JS:mainfrom
bfs2021:fix/trace-export-dom-test-hint
Open

bfs2021 wants to merge 1 commit into
Avenx-JS:mainfrom
bfs2021:fix/trace-export-dom-test-hint

Conversation

@bfs2021

@bfs2021 bfs2021 commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Problem

avenx trace export closes with:

Run it with your test runner, e.g. `node --test test/counter-click.test.js`.

The generated test mounts a component through mountTestComponent, and node --test has no DOM. Following the printed instruction produces a wall of render-failure output (AVX_R08, AVX_R37) that points at the framework rather than at the instruction. The generated file's header also never mentions the DOM requirement, so once the terminal output is gone the file does not carry its own setup — unlike the --with-test scaffold, which documents it.

Root cause

The closing hint in traceExport hard-coded node --test, and generateTest never emitted the DOM setup block that templates/component/component.test.js.template writes for --with-test.

Fix

  • bin/commands/trace.js: the closing hint now prints npx vitest run <path> using the path the export actually wrote, including when --out is passed. That is the runner the component scaffold and docs/src/content/docs/api-reference/testing.md recommend for component tests.
  • lib/core/trace/exportTest.js: generated tests now include the scaffold-style setup header — install vitest and happy-dom, set test: { environment: 'happy-dom' }, run npx vitest run — so the file stands on its own.

Testing

  • New test/unit/traceExportSetup.test.js asserts the generated header contains the DOM setup, and that the CLI message names npx vitest run plus the file actually written (both the --out path and the default path), and no longer mentions node --test.
  • node test/run-tests.js traceExport: 2/3 files pass. test/system/traceExport.test.js fails at its recording step with ERR_UNSUPPORTED_ESM_URL_SCHEME because --import receives a Windows absolute path. The same failure reproduces at HEAD with these changes stashed, so it is pre-existing on Windows and unrelated to this change.
  • npm run lint: passes.

Checklist

  • npm run lint passes
  • Tests added or updated where appropriate
  • npm test (full suite) not run; affected trace-export suites were run as described above
  • Documentation: no docs referenced the printed hint, so none needed changing

Fixes #1765

`avenx trace export` suggested running the generated test with
`node --test <file>`. That runner has no DOM, so mounting the component
fails and the resulting error blames the framework instead of the
instruction. The generated file's header also never mentioned the DOM
requirement, unlike the `--with-test` scaffold.

Print `npx vitest run <path>` naming the file that was written, and emit
the scaffold's setup header (vitest and happy-dom, plus the environment
setting) in generated tests so the file carries its own instructions.

Fixes Avenx-JS#1765

This branch has not been deployed

No deployments
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.

Bug: avenx trace export recommends node --test, which has no DOM, and the generated header omits the setup

1 participant