PlantGuard

PlantGuard AI — Testing & Verification Guide

PlantGuard AI uses a unified testing strategy across both workspaces using Vitest, Testing Library, Supertest, and fake-indexeddb.


1. Test Command Matrix

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

2. Server Test Suite (server/src/test/)

Server tests use Supertest to test Express routes without binding to physical network ports:

2.1 Covered Scenarios

Running Server Tests:

npm --prefix server run test

3. Client Test Suite (client/src/)

Client tests execute in a simulated browser environment powered by jsdom and fake-indexeddb:

3.1 Covered Scenarios

Running Client Tests:

npm --prefix client run test

4. Pre-Commit / Pre-Deployment Full Check

Before pushing code or deploying releases, execute the full check pipeline:

npm run check

This runs:

  1. npm --prefix client run typecheck
  2. npm --prefix server run typecheck
  3. npm --prefix server run test
  4. npm --prefix client run test
  5. npm --prefix client run build
  6. npm --prefix server run build

All steps must succeed with exit code 0.