Testing
npm test # vitest run
npm run test:watch # vitest
npx vitest run src/features/contacts
| Runner | Vitest 5, configured in vite.config.ts |
| Environment | jsdom, setup in src/test/setup.ts (jest-dom matchers) |
| Files | src/**/*.test.{ts,tsx} (64 at last count), for example src/api/client.test.ts, src/features/contacts/*.test.tsx |
| Fixtures | src/test/me.ts (a /rest/crm/me/ payload with capabilities and scope) |
What to test
- Capability gating: a route or button is hidden without the capability and shown with it (render with a
mefixture). - API functions in
features/<area>/api.ts: path, method, trailing slash, query encoding; mockfetch. - Form validation and 400/409 handling, since those bodies drive the UI.
- The dev send guard.
What not to do
- Do not hit the real backend from tests; mock at
fetch. - Do not put real names, emails or addresses in fixtures.
CI does not run the suite yet (the develop workflow only builds and deploys); run it before opening a pull request. Adding a npm test step to the workflow is on the known gaps list.