# Testing signals — vitejs/vite

> Canonical page: https://codevetter.com/unpack/vite/testing-signals

# Testing signals — vitejs/vite

Scanned commit 1544bb1b7ac92f775e9d0dea97954c99cc6cbd43 (2026-09-22). Generated by codevetter codevetter 1.12.0 on 2026-09-22.

Testing is Vitest-only, split into two configs. `vitest.config.ts` collects 68 unit specs from `**/__tests__/**/*.spec.[tj]s` inside `packages/`, running with `isolate: false` and a 20s timeout. `vitest.config.e2e.ts` collects 109 integration specs from `playground/**`, driving a real Playwright Chromium browser against real Vite servers. The integration suite is the primary correctness net and runs three times in CI — serve, bundled-dev, and build — across Node 20/22/24/26 on Ubuntu plus macOS and Windows. The weakest spot is that unit coverage of the largest files is thin relative to their size: `css.ts` (3685 lines) and `hmr.ts` (1193 lines) have no dedicated unit spec, and are covered only indirectly through playground fixtures.
- Unit tests use `vitest.config.ts` with `include: ['**/__tests__/**/*.spec.[tj]s']`, explicitly excluding `./playground/**` and `./playground-temp/**`, `testTimeout: 20000`, `isolate: false`, and an alias mapping `vite/module-runner` to the TypeScript source rather than `dist`. — [vitest.config.ts](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/vitest.config.ts)
- There are 68 unit spec files under `packages/**/__tests__/`, concentrated in `packages/vite/src/node/__tests__/` (config, build, dev, env, html, http, resolve, scan, utils, oxc, packages, shortcuts, external, environment, filterRegex, assetSource) plus `plugins/`, `optimizer/` and `utils/` subdirectories. — [packages/vite/src/node/__tests__/](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/packages/vite/src/node/__tests__/) [packages/vite/src/node/__tests__/config.spec.ts](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/packages/vite/src/node/__tests__/config.spec.ts)
- Integration tests use `vitest.config.e2e.ts` with `include: ['./playground/**/*.spec.[tj]s']`, `globalSetup: playground/vitestGlobalSetup.ts`, `setupFiles: playground/vitestSetup.ts`, `reporters: 'dot'`, and a timeout of 50s on CI / 30s locally (Infinity under `PWDEBUG`). — [vitest.config.e2e.ts#L36-78](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/vitest.config.e2e.ts#L36-L78)
- `vitestGlobalSetup.ts` launches a shared `chromium.launchServer()` (headed when `VITE_DEBUG_SERVE` is set, `--no-sandbox` on CI), shares the endpoint via `project.provide('wsEndpoint', ...)`, then copies only the playground directories actually referenced by the selected test files into `playground-temp/`. — [playground/vitestGlobalSetup.ts#L11-60](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/playground/vitestGlobalSetup.ts#L11-L60)
- `vitestSetup.ts` exposes the per-test harness — `page`, `viteTestUrl`, `browserLogs`, `browserErrors`, `serverLogs`, and mode flags `isBuild`/`isServe`/`isBundledDev`/`isBundled` — aliased in tests as `~utils`. — [playground/vitestSetup.ts#L64-120](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/playground/vitestSetup.ts#L64-L120) [vitest.config.e2e.ts#L38-43](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/vitest.config.e2e.ts#L38-L43)
- The same 109 playground specs are executed under three different modes selected by env vars: default serve, `VITE_TEST_BUNDLED_DEV=1` (`test-serve-bundled`), and `VITE_TEST_BUILD=1` (`test-build`), with `NODE_ENV` set to `production` only in the build run. — [package.json#L21-25](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/package.json#L21-L25) [vitest.config.e2e.ts#L4-6](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/vitest.config.e2e.ts#L4-L6) [vitest.config.e2e.ts#L70-73](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/vitest.config.e2e.ts#L70-L73)
- Known gaps in bundled-dev mode are tracked as an explicit 22-entry `bundledDevExclude` array in `vitest.config.e2e.ts` — including `fs-serve`, `csp`, `hmr-ssr`, `optimize-deps`, `tailwind` and all four `worker` variants — with the convention that partial failures use `test.skipIf(isBundledDev)` instead of listing the file. — [vitest.config.e2e.ts#L11-34](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/vitest.config.e2e.ts#L11-L34) [CONTRIBUTING.md#L155](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/CONTRIBUTING.md#L155)
- CI runs the full matrix Node 20/22/24/26 on ubuntu-latest plus macos-latest@24 and windows-latest@24.15.0 (pinned to work around nodejs/node#63638), with `fail-fast: false` and a 20-minute timeout per job. — [.github/workflows/ci.yml#L61-80](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/.github/workflows/ci.yml#L61-L80)
- The CI `test` job runs all four suites sequentially — `test-unit`, `test-serve`, `test-serve-bundled`, `test-build` — after a `pnpm run build`, and a separate `lint` job runs eslint, `pnpm format && git diff --exit-code`, `pnpm typecheck`, and `pnpm test-docs`. — [.github/workflows/ci.yml#L138-200](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/.github/workflows/ci.yml#L138-L200)
- CI skips the whole test matrix when only docs, `.github/**` (excluding `ci.yml`), `packages/create-vite/template**`, or `**.md` changed, via a `changed` job using `tj-actions/changed-files` with `only_changed`. — [.github/workflows/ci.yml#L34-59](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/.github/workflows/ci.yml#L34-L59)
- Flakiness is managed with environment knobs rather than retries in test code: `VITEST_SEGFAULT_RETRY: 3` and `NODE_OPTIONS: --max-old-space-size=6144` are set globally in the workflow env block. — [.github/workflows/ci.yml#L3-10](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/.github/workflows/ci.yml#L3-L10)
- A scheduled Semgrep scan (`--config auto`, weekly on Tuesdays) uploads SARIF to GitHub code scanning, but explicitly excludes `playground` and `__tests__` and disables the `detect-non-literal-regexp` rule — so dynamic regex construction in source is not flagged. — [.github/workflows/semgrep.yml](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/.github/workflows/semgrep.yml)
- Type-level tests exist as a separate mechanism: `src/node/__tests_dts__` and `src/module-runner/__tests_dts__` are compiled by the package `typecheck` script (`tsc -p src/node/__tests_dts__`), using `@type-challenges/utils`. — [packages/vite/package.json#L60](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/packages/vite/package.json#L60) [package.json#L46](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/package.json#L46)
- Type output is separately validated after bundling: `build-types` runs `rolldown.dts.config.ts` then `tsc --project tsconfig.check.json`, and CONTRIBUTING documents `pnpm run build-types-check` as the guard against d.ts leaking devDependency types. — [packages/vite/package.json#L55-58](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/packages/vite/package.json#L55-L58) [CONTRIBUTING.md#L66-72](https://github.com/vitejs/vite/blob/1544bb1b7ac92f775e9d0dea97954c99cc6cbd43/CONTRIBUTING.md#L66-L72)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
