CodeVetter · Repo Unpack · Testing signals
vuejs/core
Vitest is the only test runner, with 196 spec files collocated in per-package `__tests__` directories and five projects configured in `vitest.config.ts` to isolate environment needs. Coverage is v8-based over `packages/*/src/**` with an explicit exclusion list that documents what is deliberately not unit-tested. Type correctness is tested separately by compiling `packages-private/dts-test` against generated `.d.ts` files, and treeshaking is asserted by a bespoke script. There is no mutation testing, no snapshot-free contract layer, and no coverage threshold gate in CI.
- Five Vitest projects are declared: `unit` (node env, excludes e2e and the DOM packages), `unit-gc` (forks pool with `--expose-gc` for two server-renderer specs), `unit-jsdom` (vue/vue-compat/runtime-dom), `e2e` (jsdom) and `e2e-browser` (real Chromium via `@vitest/browser-playwright`, only for Transition and TransitionGroup).
- Coverage explicitly excludes `packages/vue-compat/**`, `vue/src/dev.ts`, `vue/src/runtime.ts`, `runtime-core/src/profiling.ts`, `featureFlags.ts`, `customFormatter.ts`, and — with a comment saying they are covered by e2e instead — `hydrationStrategies.ts` and `runtime-dom/src/components/Transition*`.
- `scripts/setup-vitest.ts` installs three custom matchers — `toHaveBeenWarned`, `toHaveBeenWarnedLast`, `toHaveBeenWarnedTimes` — built on a mocked `console.warn`, which is the house idiom for asserting dev-only warning behaviour throughout the suite.
- Every published package carries a `__tests__` directory (compiler-core, compiler-dom, compiler-sfc, compiler-ssr, reactivity, runtime-core, runtime-dom, runtime-test, server-renderer, shared, vue, vue-compat), totalling 196 `.spec.ts` files.
- Compiler tests lean on snapshots (`__snapshots__` directories exist under compiler-core, compiler-dom and compiler-sfc), which means codegen changes surface as large snapshot diffs rather than assertion failures.
- The e2e suite drives real browser behaviour across 14 specs including `todomvc.spec.ts`, `commits.spec.ts`, `markdown.spec.ts`, `grid.spec.ts`, `svg.spec.ts`, `vModel.spec.ts`, `memory-leak.spec.ts`, `ssr-custom-element.spec.ts` and `trusted-types.spec.ts`, with shared drivers in `e2eUtils.ts`/`e2eBrowserUtils.ts`.
- `pnpm test-e2e` first builds the global dev bundle (`node scripts/build.js vue -f global -d`) and only then runs the e2e projects, so e2e results reflect the bundled artifact rather than the aliased source.
- Type-level testing is a separate pipeline: `test-dts` runs `build-dts` then type-checks `packages-private/dts-built-test` and `packages-private/dts-test`, whose ~20 `.test-d.ts(x)` files cover defineComponent, h, tsx, directives, inject, watch, scheduler, reactivity and custom elements.
- `scripts/verify-treeshaking.js` reads the built dev and prod bundles and asserts dead-code elimination; it runs in CI as a step of the e2e-test job, making it the guard for the `__DEV__`/`__FEATURE_*` flag scheme.
- Test files get relaxed lint rules — `no-console`, `no-restricted-globals` and `no-restricted-syntax` are off under `**/__tests__/**` — but `vitest/no-disabled-tests` and `vitest/no-focused-tests` are errors, so a stray `.only` or `.skip` fails the lint job.
- Benchmarks are first-class: `prebench` builds reactivity as esm-browser and `bench`/`bench-compare` run `vitest bench --project=unit` writing to and diffing against `temp/bench.json`.
- CI does not enforce a coverage threshold — `test-coverage` exists as a script but no workflow invokes it; the jobs run `test-unit`, `test-e2e`, lint, `check` and `test-dts` only.
- The most recent commit follows the repo's expected pattern of pairing a runtime fix with a regression test: `fix(suspense): skip rendering async components unmounted while pending` changed 3 lines in `Suspense.ts` and added 56 lines to `Suspense.spec.ts`.