Expense Analyser Test Builder
Use Vitest + @vue/test-utils + jsdom as the default testing framework for this project.
Read references/project-testing-strategy.md before implementation.
Use templates from assets/ for setup and first tests.
Workflow
- •Install test tooling.
- •Add dev dependencies:
vitest,@vitest/coverage-v8,@vue/test-utils,jsdom. - •Keep
npmas package manager to match existing lockfile.
- •Add test config and scripts.
- •Extend
vite.config.tswith atestblock or createvitest.config.ts. - •Add scripts in
package.json:- •
test:vitest run - •
test:watch:vitest - •
test:coverage:vitest run --coverage
- •
- •Add setup file (
src/tests/setup.ts) and include it in Vitest config.
- •Establish folder layout.
- •Component tests:
src/components/__tests__/*.spec.ts - •Store tests:
src/stores/**/__tests__/*.spec.ts - •Service tests:
src/services/__tests__/*.spec.ts - •Shared test utils:
src/tests/*
- •Add first coverage in this order.
- •Pure utilities/models with no Vue runtime dependency.
- •Stores with mocked services.
- •Components with store and router mocks.
- •Service wrappers with mocked axios behavior.
- •Handle known project side effects.
- •Mock
TextractNotificationService.start/stopin tests that touch auth flow. - •Mock
useNotificationStorewhen testinguseAuthStore.login. - •Stub router pushes and route guards instead of running full navigation for unit tests.
- •Validate in CI-style order.
- •Run
npm run test. - •Run
npm run test:coverage. - •Run
npm run type-check. - •Run
npm run lint.
Coverage Targets
Prioritize high-risk paths:
- •Auth session transitions (
login,checkSession,logout) - •Expense create/list/delete flows in store actions
- •Notification rendering branches (friend request vs normal message)
- •Error handling paths in services (
axios.isAxiosErrorbranches)
Guardrails
- •Do not call real backend APIs in unit tests.
- •Do not rely on shared mutable store state across tests; reset Pinia and mocks per test.
- •Keep tests deterministic; avoid sleeps/timeouts unless testing retry/debounce logic.
- •Add tests near the domain they cover to keep maintenance cost low.