Repository navigation
🐛 Add missing vite dev dependency so the test suite can start - #6834
Conversation
`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]>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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]>
There was a problem hiding this comment.
🟡 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.0todevDependenciesto satisfy Vitest’s peer dependency. - Bump
@vitest/coverage-v8from4.1.11to^5.0.0. - Update
package-lock.jsonaccordingly (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.
| "tsx": "^4.23.13", | ||
| "typescript": "^6", | ||
| "vite": "^7.0.0", | ||
| "vitest": "^5.0.0", |
|
@clubanderson: The following test failed, say
DetailsInstructions 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. |
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
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]>
…, #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]>
The problem
npm run testandnpm run type-checkfail on every open PR and on a clean checkout ofmain, before a single test executes:[email protected]declaresvite(^6.4.0 || ^7.0.0 || ^8.0.0) as a peer dependency, andpackage.jsonnever lists it — so nothing installs it. Consequences:Run unit testsdies at startup on every PR.TypeScript & ESLintfails becausetsccannot resolve theviteimport invitest.config.ts.npm run buildfails at itsRunning TypeScriptstep for the same reason, which is why the Netlify deploy preview fails on all open PRs.@vitest/coverage-v8was also left at4.1.11while vitest moved to 5 (npm lsflags it as an invalid peer). CI runsvitest run --coverage, so it has to match the runner major.The fix
vite@^7.0.0todevDependencies@vitest/coverage-v8to^5.0.0Two lines plus the lockfile. No source or test changes.
Verification
Ran the exact CI command locally,
npx vitest run --coverage:Coverage enabled with v8npm run type-checkno longer reportsvitest.config.tsOne 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.initializeinsrc/lib/Mermaid.tsxis 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
viteactually installed,tscandeslintget far enough to surface two more small breakages, both fixed in the follow-up commit:vitest.config.tstype error —transformWithEsbuildreturns a sourcemap whosesourcesContentis(string | null)[], while rollup'sTransformResultexpectsstring[]. The plugin now returnscode/mapexplicitly with a narrow cast and a comment. This was the error blockingnpm run buildat itsRunning TypeScriptstep, and therefore the Netlify deploy preview.@typescript-eslint/no-throw-literalwas renamed toonly-throw-error, so eslint reported "Definition for rule was not found" as a hard error inhealthz-route.test.tsandsearch-route.non-error-throw.test.ts.Current local state on this branch:
npx vitest run --coveragenpm run type-checknpm run lintThe single remaining failure is still
Mermaid.test.tsx, unchanged and untouched by this PR. I dug into it: the module-loadmermaid.initialize()call does execute against the mock, but vitest 5 gives the test'sawait import('mermaid')a different mock instance than the onesrc/lib/Mermaid.tsxreceived, so the call is invisible to the assertion. Hoisting the spy viavi.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.