Files
fdbck/package.json
mAi a0765c9bf7 test: vitest + jsdom for Svelte component tests
Sets up the runtime split for §3.A's per-question-type modules: each type's
ParticipantInput / BuilderEditor / ResultsBlock will live in its own .svelte
file and want testable input handling. The pure logic (schema, isAnswerEmpty,
ingest, csvColumns, etc.) stays on `bun test`; the Svelte components run on
vitest.

Why two runners:

- Bun test doesn't apply the `browser` export condition when resolving ESM,
  so it picks Svelte 5's `index-server.js` and @testing-library/svelte's
  mount() throws lifecycle_function_unavailable.
- Vitest reuses the existing vite-plugin-svelte and applies the right
  conditions natively. Run via `bun --bun vitest` so vitest itself executes
  on bun (Node 18 is too old for vitest 4's node:util.styleText usage).

Files:

- New vitest.config.ts (jsdom env, svelte plugin, browser conditions, picks
  up src/**/*.svelte.test.ts files only)
- New src/test-setup/vitest.ts — afterEach cleanup so consecutive render()
  calls don't pollute each other's getByTestId lookups
- New src/lib/components/SmokeTest.svelte + .svelte.test.ts — sanity check
  that the runner actually mounts a Svelte 5 component and reads props
- package.json scripts split: `test:server` (bun, 5 server files),
  `test:components` (vitest), `test` runs both
- Pinned @sveltejs/vite-plugin-svelte to ^5.0.0 (v7 needs Node 22+ for
  node:util.styleText; ours is on Node 18)

devDeps added (test-only): vitest, @testing-library/svelte,
@testing-library/jest-dom, jsdom.

54 server tests + 2 component tests pass. svelte-check + build clean.
2026-05-07 20:04:10 +02:00

36 lines
1.1 KiB
JSON

{
"name": "fdbck",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"start": "node build/index.js",
"test:server": "bun test ./src/lib/server/rate-limit.test.ts ./src/lib/server/public-scope.test.ts ./src/lib/server/results.test.ts ./src/lib/server/admin-route.test.ts ./src/lib/server/feedback-pure.test.ts",
"test:components": "bun --bun vitest run --config vitest.config.ts",
"test": "bun run test:server && bun run test:components"
},
"devDependencies": {
"@sveltejs/adapter-node": "^5.5.4",
"@sveltejs/kit": "^2.15.0",
"@sveltejs/vite-plugin-svelte": "^5.0.0",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/svelte": "^5.3.1",
"@types/bun": "^1.3.13",
"jsdom": "^29.1.1",
"svelte": "^5.0.0",
"svelte-check": "^4.0.0",
"typescript": "^5.0.0",
"vite": "^6.0.0",
"vitest": "^4.1.5"
},
"dependencies": {
"@supabase/supabase-js": "^2.104.1",
"postgres": "^3.4.9",
"zod": "^4.3.6"
}
}