Vitest ^4.0.18 is installed but completely unconfigured. This task sets up the foundation so that subsequent test-writing tasks can just add .test.js files and they work.

Part of Add tests and CI integration (sub-task 1 of 4).

Vitest config

Create vitest.config.js (or extend vite.config.js ):

  • Resolve $lib alias to src/lib
  • Resolve $styles alias to src/styles
  • Mock or stub $app/* imports (paths, environment, stores, navigation)
  • Set environment: 'node' as default (override per-file for DOM tests)
  • Configure include pattern: src/**/*.test.{js,ts}

Package scripts

Add to package.json:

"test": "vitest",
"test:ci": "vitest run"

test runs in watch mode for development. test:ci runs once and exits for CI.

CI integration

Update .github/workflows/ci.yml to add test step before build:

- run: pnpm install --frozen-lockfile
- run: pnpm lint
- run: pnpm check
- run: pnpm test:ci
- run: pnpm build

Smoke test

Create one minimal test file (src/lib/__tests__/smoke.test.js) to verify the setup works end-to-end before writing real tests.

Dependencies to consider

  • @testing-library/svelte -- for component tests (can be added later in the component tests task)
  • jsdom or happy-dom -- for tests that need DOM APIs (scroll-to.js, component tests)

Testing infra

Foundation for all tests

A static site template built with SvelteKit.

Sveleton, 2025