Skip to content

Add Vitest testing infrastructure#297

Open
Just-Insane wants to merge 3 commits intodevfrom
feat/testing-setup
Open

Add Vitest testing infrastructure#297
Just-Insane wants to merge 3 commits intodevfrom
feat/testing-setup

Conversation

@Just-Insane
Copy link
Contributor

Sets up a complete testing stack so contributors can write and run tests as part of their PRs.

What's included

  • Vitest as the test runner (reuses existing Vite config, Jest-compatible API)
  • @testing-library/react + @testing-library/user-event for component/hook tests
  • @vitest/coverage-v8 for V8-native coverage reports (coverage/ is gitignored)
  • Standalone vitest.config.ts that excludes Cloudflare/PWA/compression plugins
  • src/test/setup.ts that loads @testing-library/jest-dom matchers globally

New scripts

Command Purpose
pnpm test Watch mode (dev)
pnpm test:run Single run (CI)
pnpm test:ui Browser results UI
pnpm test:coverage Run + HTML + lcov reports

CI

pnpm test:run is now a required check in quality-checks.yml alongside lint/typecheck/knip.

Example tests (4 files, 34 tests)

Included as working examples for contributors:

  • colorMXID.test.ts — basic pure function tests
  • common.test.tsit.each table-driven tests
  • findAndReplace.test.ts — algorithmic utility, edge cases
  • sort.test.ts — factory functions with lightweight object stubs

Docs

docs/TESTING.md covers: running tests, where to put files, and examples for utilities, components, hooks, and mocking. CONTRIBUTING.md updated to include test:run in the PR checklist.

@Just-Insane Just-Insane marked this pull request as ready for review March 16, 2026 15:30
@Just-Insane Just-Insane requested a review from a team March 16, 2026 15:30
@github-actions
Copy link
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

Status Preview URL Commit Alias Updated (UTC)
✅ Deployment successful! https://pr-297-sable.raspy-dream-bb1d.workers.dev b2696f4 pr-297 Mon, 16 Mar 2026 17:48:25 GMT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant