Skip to content

Feat/vitest test infrastructure.apits unit tests and ci pipeline - #31

Merged
Dannyswiss1 merged 2 commits into
mainfrom
feat/Vitest-test-infrastructure.apits-unit-tests-and-CI-pipeline
Aug 3, 2026
Merged

Feat/vitest test infrastructure.apits unit tests and ci pipeline#31
Dannyswiss1 merged 2 commits into
mainfrom
feat/Vitest-test-infrastructure.apits-unit-tests-and-CI-pipeline

Conversation

@Dannyswiss1

Copy link
Copy Markdown
Contributor

Add Vitest test infrastructure, api.ts unit tests, and CI pipeline

Summary

  • Set up Vitest + React Testing Library (jsdom environment, jest-dom matchers, coverage via v8) as the project's test infrastructure, with a smoke test on Badge proving the pipeline end to end.
  • Added a full unit test suite for the mock API layer (src/lib/api.ts), covering all 12 exported functions, their audit-log side effects, sort ordering, and not-found paths — using fake timers to flush the artificial network latency deterministically instead of waiting on real time.
  • Added a GitHub Actions CI workflow that runs lint, typecheck/build, and tests on every push to main and every PR, scoped to client/.

Details

  • vite.config.ts extended via vitest/config's defineConfig with a test block (jsdom, setupFiles, v8 coverage reporters)
  • src/test/setup.ts wires in @testing-library/jest-dom
  • New scripts: npm test, npm run test:watch, npm run test:coverage
  • src/lib/api.test.ts resets the module registry per test (the mock API holds mutable module-level state) and uses vi.advanceTimersByTimeAsync to flush delays
  • .github/workflows/ci.yml: Node 22, npm cinpm run lintnpm run buildnpm test
  • client/README.md documents the test commands; coverage/ added to .gitignore

Test plan

  • npm run lint — clean (only 2 pre-existing, unrelated fast-refresh warnings)
  • npm run build — type-checks and builds clean
  • npm test — 20/20 tests passing
  • npm run test:coverage — coverage report generates correctly
  • CI workflow YAML validated (js-yaml parse)

Closes #3
Closes #4
Closes #5

@Dannyswiss1
Dannyswiss1 merged commit bbeb5b2 into main Aug 3, 2026
1 check passed
Dashetty added a commit to Dashetty/LockA-Health-Provider-Client that referenced this pull request Aug 3, 2026
Upstream added Vitest tests and a CI workflow (PR LockA-Medical-Passport#31) after the guide
was first drafted. Update the testing section with the real commands
(npm test, test:watch, test:coverage), require tests on changes, and
note the CI gate so contributors know what must pass before merging.

Closes LockA-Medical-Passport#29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant