CodeVetter · Repo Unpack · Testing signals
sveltejs/svelte
Testing is Vitest-driven with a fixture-directory convention: 22 suites under `packages/svelte/tests/`, each a `test.ts` plus a `samples/` directory where every subdirectory is one test, optionally configured by a `_config.js`. Coverage is enormous by fixture count — 1,209 legacy runtime samples, 1,054 runes runtime samples, 335 validator samples, 184 CSS samples — and the runtime suites multiply each by four variants (dom, hydrate, ssr, async-ssr). Real-browser coverage is narrow: only `runtime-browser` (35 samples) and the custom-elements samples run under Playwright Chromium. CI runs the full suite on Node 20/22/24 across Windows, macOS, and Ubuntu, plus a no-async pass, a tsgo typecheck, a lint/types-drift gate, and a benchmark job.
- Vitest 4 is the single test runner, configured once at the repo root with `include` patterns `packages/svelte/**/*.test.ts`, `packages/svelte/tests/*/test.ts`, and `packages/svelte/tests/runtime-browser/test-ssr.ts`, and `**/samples/**` excluded so fixtures are never collected as tests.
- The global `testTimeout` is raised to 30s with an in-file rationale: dev-mode tests that trip `effect_update_depth_exceeded` allocate ~1000 Error objects per flush for stack tracking, which overruns the 5s default under Vitest 4.
- `tests/suite.ts` provides the two harness primitives: `suite()` (one `it` per sample dir) and `suite_with_variants()` (one `it` per dir × variant, with a `should_skip_variant` hook returning `true` to skip or `'no-test'` to omit entirely).
- Test selection supports both `pnpm test <suite> -t <name>` and a `FILTER` env var that compiles to an anchored or `/regex/` RegExp in `suite.ts`, plus per-config `skip`/`solo`/`timeout` flags on `BaseTest`.
- Runtime suites run four variants per sample — `dom`, `hydrate`, `ssr`, `async-ssr` — with `async-ssr` gated on both runes mode and `async_mode` (i.e. `process.env.SVELTE_NO_ASYNC !== 'true'`).
- Fixture counts skew heavily toward runtime behaviour: `runtime-legacy/samples` (1209), `runtime-runes/samples` (1054), `validator/samples` (335), `css/samples` (184), `compiler-errors/samples` (146), `server-side-rendering/samples` (132).
- Real-browser testing is limited to `tests/runtime-browser/test.ts`, which launches a single Chromium via `@playwright/test`, bundles each sample with `esbuild`, and runs `dom`/`hydrate` variants plus a separate `custom-elements-samples` suite — with `retry: 1` on CI because 'browser tests are brittle and slow on CI'.
- XHTML/XML-document behaviour gets its own environment: `vitest-xhtml-environment.ts` wraps the jsdom builtin with `contentType: 'application/xhtml+xml'`, consumed by `tests/runtime-xhtml/test.ts` via a `@vitest-environment` pragma (13 samples).
- Unit tests colocated with source are rare — only `src/utils.test.ts`, `src/internal/client/proxy.test.ts`, `src/internal/client/error-handling.test.ts`, the four `src/reactivity/*.test.ts` files, and `src/internal/server/{crypto,hydratable,renderer}.test.ts`.
- Snapshot-style suites (`snapshot`, `parser-modern`, `parser-legacy`, `print`, `sourcemaps`) assert generated output against checked-in expectations and are regenerated with `UPDATE_SNAPSHOTS=true pnpm test`.
- CI's `Tests` job matrixes Node 20 across windows/macOS/ubuntu plus Node 22 and 24 on ubuntu, installs only Chromium (`PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'` then `pnpm playwright install chromium`), with a 15-minute timeout.
- A dedicated `TestNoAsync` job re-runs only `runtime-runes` with `SVELTE_NO_ASYNC: true`, guarding the non-async code path that the default run never exercises.
- The `Lint` job doubles as a drift gate: after `pnpm build` it fails if `git status --porcelain` is non-empty (generated types out of date) and separately checks `documentation/docs/07-misc/.generated/` for a stale browser-support page.
- Coverage is configured (v8 provider, `lcov` + `html`, scoped to `packages/svelte/src/**`, `reportOnFailure: true`) but no CI job invokes it or enforces a threshold.
- `tests/manual/` exists as a suite directory with no `test.ts` and no samples, so nothing in it runs under `pnpm test`. (inferred)