Skip to content

🐛 Add missing vite dev dependency so the test suite can start - #6834

Merged
clubanderson merged 2 commits into
mainfrom
fix/add-missing-vite-dev-dependency
Sep 9, 2026
Merged

clubanderson merged 2 commits into
mainfrom
fix/add-missing-vite-dev-dependency

Conversation

@clubanderson

@clubanderson clubanderson commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

The problem

npm run test and npm run type-check fail on every open PR and on a clean checkout of main, before a single test executes:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'vite'
  imported from node_modules/vitest/dist/chunks/index.B89dZ0-N.js

[email protected] declares vite (^6.4.0 || ^7.0.0 || ^8.0.0) as a peer dependency, and package.json never lists it — so nothing installs it. Consequences:

  1. Run unit tests dies at startup on every PR.
  2. TypeScript & ESLint fails because tsc cannot resolve the vite import in vitest.config.ts.
  3. npm run build fails at its Running TypeScript step for the same reason, which is why the Netlify deploy preview fails on all open PRs.

@vitest/coverage-v8 was also left at 4.1.11 while vitest moved to 5 (npm ls flags it as an invalid peer). CI runs vitest run --coverage, so it has to match the runner major.

The fix

  • Add vite@^7.0.0 to devDependencies
  • Bump @vitest/coverage-v8 to ^5.0.0

Two lines plus the lockfile. No source or test changes.

Verification

Ran the exact CI command locally, npx vitest run --coverage:

  • Before: startup error, 0 tests run
  • After: 77 test files, 795 tests, Coverage enabled with v8
  • npm run type-check no longer reports vitest.config.ts

One known remaining failure, deliberately not fixed here

src/__tests__/Mermaid.test.tsx → "calls mermaid.initialize with startOnLoad disabled on module load" still fails.

That failure is not introduced by this PR — it was simply invisible, because the runner never got far enough to execute it. It looks like fallout from the vitest 4 → 5 upgrade: the module-load call to mermaid.initialize in src/lib/Mermaid.tsx is no longer observed on the mocked module (the mock records 0 calls even in the first test in the file). That deserves a focused fix rather than being bundled into a dependency correction, so I have left it for a follow-up.

So this PR takes CI from "nothing runs" to "794 of 795 pass, with one clearly identified pre-existing bug".


Update: with vite actually installed, tsc and eslint get far enough to surface two more small breakages, both fixed in the follow-up commit:

  • vitest.config.ts type error — transformWithEsbuild returns a sourcemap whose sourcesContent is (string | null)[], while rollup's TransformResult expects string[]. The plugin now returns code/map explicitly with a narrow cast and a comment. This was the error blocking npm run build at its Running TypeScript step, and therefore the Netlify deploy preview.
  • Two stale eslint disable comments — @typescript-eslint/no-throw-literal was renamed to only-throw-error, so eslint reported "Definition for rule was not found" as a hard error in healthz-route.test.ts and search-route.non-error-throw.test.ts.

Current local state on this branch:

Command Before After
npx vitest run --coverage startup error, 0 tests 794 / 795 pass
npm run type-check 3 errors clean
npm run lint 2 errors, 69 warnings 0 errors, 71 warnings

The single remaining failure is still Mermaid.test.tsx, unchanged and untouched by this PR. I dug into it: the module-load mermaid.initialize() call does execute against the mock, but vitest 5 gives the test's await import('mermaid') a different mock instance than the one src/lib/Mermaid.tsx received, so the call is invisible to the assertion. Hoisting the spy via vi.hoisted() does not fix it either, which suggests the test module itself is evaluated in two module graphs. That is a genuine vitest 5 behaviour change deserving its own investigation, so I have deliberately left the test exactly as it is rather than weaken or skip it to force a green tick.

`npm run test` and `npm run type-check` currently fail on every PR and on
a clean checkout of main:

    Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'vite'
      imported from node_modules/vitest/dist/chunks/index.B89dZ0-N.js

vitest 5.0.0 declares vite (^6.4 || ^7 || ^8) as a peer dependency, and
package.json never lists it, so nothing installs it. Every test run dies
at startup before a single test executes, and tsc cannot resolve the
`vite` import in vitest.config.ts, which also fails `npm run build` at
its "Running TypeScript" step.

`@vitest/coverage-v8` was also left at 4.1.11 while vitest moved to 5,
which npm reports as an invalid peer; CI runs `vitest run --coverage`,
so it needs to match the runner major.

- Add vite ^7.0.0 to devDependencies
- Bump @vitest/coverage-v8 to ^5.0.0

Verified locally with the exact CI command, `npx vitest run --coverage`:
the suite now starts and runs 795 tests across 77 files with coverage
enabled, and `npm run type-check` no longer reports vitest.config.ts.

One test, src/__tests__/Mermaid.test.tsx, still fails. That failure was
previously invisible because the runner never started, and it is a
separate pre-existing issue from the vitest 4 to 5 upgrade rather than
something this change introduces: the module-load call to
mermaid.initialize is no longer observed on the mocked module. Left for
a focused follow-up rather than mixed in here.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Andrew Anderson <[email protected]>
Copilot AI lite review requested due to automatic review settings September 9, 2026 17:32
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Sep 9, 2026
@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 9, 2026
@github-actions github-actions Bot added frontend dependencies Pull requests that update a dependency file json labels Sep 9, 2026
Follow-on to adding the missing vite dependency: with vite actually
installed, `tsc` can now resolve vitest.config.ts and reports a real type
error, and eslint reaches two inline disable comments naming a rule that
no longer exists.

- vitest.config.ts: transformWithEsbuild returns a sourcemap whose
  sourcesContent is (string | null)[], while rollup's TransformResult
  expects string[]. Return the code and map explicitly with a narrow cast
  and a comment explaining that the payload is equivalent at runtime.
- healthz-route.test.ts, search-route.non-error-throw.test.ts:
  @typescript-eslint/no-throw-literal was renamed to only-throw-error, so
  the disable comments referenced an unknown rule, which eslint reports as
  an error rather than ignoring.

npm run type-check is now clean and npm run lint reports 0 errors
(warnings unchanged).

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Andrew Anderson <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The updated dependency graph appears to introduce Node engine constraints (notably for coverage-related packages and Vite) that may be incompatible with the Node 20 CI/Netlify configuration.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR aims to unblock the repository’s tooling by adding Vitest’s missing vite peer dependency and aligning the coverage plugin’s major version with vitest@5, so CI and Netlify can actually reach the point of running type-checks/tests.

Changes:

  • Add vite@^7.0.0 to devDependencies to satisfy Vitest’s peer dependency.
  • Bump @vitest/coverage-v8 from 4.1.11 to ^5.0.0.
  • Update package-lock.json accordingly (new Vite/Rollup entries and coverage dependency graph updates).
File summaries
File Description
package.json Adds vite and bumps @vitest/coverage-v8 to match vitest@5.
package-lock.json Updates the lockfile to include Vite and the updated coverage plugin dependency tree.
Review details
  • Files reviewed: 4/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread package.json
Comment on lines 61 to 64
"tsx": "^4.23.13",
"typescript": "^6",
"vite": "^7.0.0",
"vitest": "^5.0.0",
@kubestellar-prow

Copy link
Copy Markdown

@clubanderson: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubestellar-docs-test 2854d5e link true /test pull-kubestellar-docs-test

Full PR test history

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@clubanderson
clubanderson merged commit f1d9330 into main Sep 9, 2026
11 of 14 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the fix/add-missing-vite-dev-dependency branch September 9, 2026 17:50
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

hivecommons-hive Bot pushed a commit that referenced this pull request Sep 15, 2026
Netlify's production build has failed on every commit to main since
2026-09-09 (`Build script returned non-zero exit code: 2`, tracked in
#6828/#6905/#6957) - the generic message never surfaced the real cause
because the maintainer-facing reporter only relays Netlify's summary
line, not the underlying build log.

Reproduced the exact failure locally (Node 20.11.1 on Linux, matching
netlify.toml's pinned NODE_VERSION and this repo's committed
package-lock.json - a Windows repro hit an unrelated, Windows-only ESM
path error and was not representative). `next build`'s "Running
TypeScript" step fails with:

    vitest.config.ts(3,37): error TS2307: Cannot find module 'rollup'
    scripts/update-version.test.ts(253,90): error TS1501: This regular
      expression flag is only available when targeting 'es2018' or later.
    scripts/update-version.test.ts(284,93): error TS1501: (same)

Root causes:

- vitest.config.ts imported `SourceMapInput` from `rollup` directly.
  vite@8 replaced rollup with rolldown as its bundler (introduced in
  #6834, which is the exact commit and date #6828 was first filed
  against), so `rollup` is no longer part of the dependency tree at
  all - not even transitively. vite re-exports the same rolldown-backed
  types under its own stable `Rollup` compat namespace specifically for
  this kind of consumer code, so that's what this now imports instead
  of reaching into whichever bundler vite happens to use internally.
- tsconfig.json's `target` was still "ES2017", predating the `/s`
  (dotAll) regex flags added in #6898 on 2026-09-12, which require
  ES2018+. Bumped to the minimum needed ("ES2018") rather than further,
  to keep this fix's blast radius as small as possible. `noEmit: true`
  means this only affects tsc's own syntax acceptance during type
  checking, not Turbopack's actual output.

Verified end-to-end: `next build` (the literal command netlify.toml
runs) now completes with exit 0 on Linux/Node 20.11.1, past type
check, static generation (232/232 pages), and page optimization - a
full reproduction of the previously-broken production build.

Signed-off-by: Bryan Saravia <[email protected]>
Co-authored-by: Claude Sonnet 5 <[email protected]>
hivecommons-hive Bot added a commit that referenced this pull request Sep 17, 2026
…, #6813) (#6990)

- scripts/netlify-ignore.test.ts: add NODE_ENV to the literal spawnEnv
  object so it satisfies NodeJS.ProcessEnv (TS2741), fixing the
  TypeScript type-check regression from #6972.
- Add src/__tests__/NavbarSubcomponents.render.test.tsx covering the
  six sub-components extracted from Navbar.tsx in #6971
  (NavbarLogo, ContributeDropdown, CommunityDropdown, GithubDropdown,
  MobileMenu, and the navbar/index.ts export surface), restoring
  src/components/navbar/** above its 95/95/90/80 coverage thresholds.
- #6813 (missing vite devDependency) was already fixed on main by
  PR #6834; verified vite is present in package.json and no longer
  reproduces, so it is not addressed here.

Signed-off-by: kubestellar-hive[bot] <[email protected]>
Co-authored-by: kubestellar-hive[bot] <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. dependencies Pull requests that update a dependency file frontend json size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants