Skip to content

bug(frontend): installed vitest/jsdom versions drift below package.json's declared floors #16919

Description

@mrveiss

Thinking Path

Found while reviewing #16902 (LLC sidebar automation entry). Its new test file,
autobot-frontend/src/__tests__/llc-sidebar-coverage.test.ts, uses the standard Node idiom
new URL('../relative/path', import.meta.url) + fileURLToPath() to read a sibling .vue file's
source for static analysis. Running it locally threw TypeError: Invalid URL — not a defect in
that PR's code, but a real, reproducible gap between what autobot-frontend/package.json declares
and what is actually installed in this checkout.

What's wrong

$ npx vitest --version
vitest/4.1.9 linux-x64 node-v24.16.0

but package.json:168 declares "vitest": "^5.0.0".

$ npm ls jsdom
autobot-vue@0.0.1 /home/martins/AutoBot-Ai/AutoBot-AI/autobot-frontend
└── (empty)

despite package.json:151 declaring "jsdom": "^30.0.1".

vitest.config.ts:21 sets environment: 'jsdom', so jsdom's own URL polyfill — not Node's native
one — governs inside every test file. Root-caused with a one-line repro that plain Node 24.16.0
handles fine, independent of any test file:

$ node -e "console.log(new URL('../foo.js', 'file:///a/b/c.js').href)"
file:///a/foo.js

The identical two-argument construction fails only under the installed jsdom environment inside
vitest, strongly suggesting a version-mismatched jsdom polyfill mishandling a file:// base URL in
the two-arg new URL() form.

Why this matters

This is the frontend twin of #16912 (frontend worktrees have no node_modules at all): a local
vitest run is not evidence about what CI will do, in either direction. A local pass carries no
information because the environment sits below the declared floor; a local fail — like this one —
can be an environment artifact rather than a defect in the code under test. A reviewer running
npx vitest run <file> needs to know this gap exists before treating either outcome as authoritative.

Reproduction

cd autobot-frontend
npx vitest --version        # -> vitest/4.1.9, package.json wants ^5.0.0
npm ls jsdom                 # -> (empty), package.json wants ^30.0.1
node -e "console.log(new URL('../foo.js', 'file:///a/b/c.js').href)"   # -> works fine in plain Node

Any new test using new URL(relativePath, import.meta.url) under environment: 'jsdom' is expected
to reproduce the TypeError: Invalid URL.

Suggested fix

Reinstall/reconcile autobot-frontend's node_modules against the versions package.json actually
declares (vitest@^5.0.0, jsdom@^30.0.1), then re-verify the repro above no longer throws. Once
fixed, a guard analogous to the backend's declared-vs-installed dependency-floor checks would catch
this drift recurring.

Model Used

Claude Sonnet 5

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfrontend

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions