PlantGuard AI uses a unified testing strategy across both workspaces using Vitest, Testing Library, Supertest, and fake-indexeddb.
All commands can be executed from the repository root:
| Command | Workspace | Target | Framework |
|---|---|---|---|
npm run test |
Monorepo | All tests across client & server | Vitest |
npm run client:test |
client |
Client components, stores, hooks, sync | Vitest + Testing Library + jsdom |
npm run server:test |
server |
Server endpoints, auth, security, storage | Vitest + Supertest |
npm run typecheck |
Monorepo | Full TypeScript verification | TypeScript (tsc) |
npm run check |
Monorepo | Typecheck + test + build pipeline | Concurrently |
npm run db:check |
server |
MongoDB connectivity check | Mongoose ping |
server/src/test/)Server tests use Supertest to test Express routes without binding to physical network ports:
/api/v1/health and /api/health return HTTP 200 with service status.GET /api/v1/ai/status returns availability without exposing API keys.POST /api/v1/ai/analyze validates image payload, rejects non-image inputs with 400, and returns structured diagnosis.Authorization: Bearer are rejected with 401..exe, .html, accepts .webp, .jpg)./api/v1/storage/files/:filename.npm --prefix server run test
client/src/)Client tests execute in a simulated browser environment powered by jsdom and fake-indexeddb:
healthy, attention, critical).ShareModal.npm --prefix client run test
Before pushing code or deploying releases, execute the full check pipeline:
npm run check
This runs:
npm --prefix client run typechecknpm --prefix server run typechecknpm --prefix server run testnpm --prefix client run testnpm --prefix client run buildnpm --prefix server run buildAll steps must succeed with exit code 0.