This document summarizes what was set up for testing your Nexpo monorepo database and API.
Location: supabase/tests/database/
Files Created:
- ✅
schema.test.sql- Tests database schema (tables, columns, types, indexes) - ✅
rls.test.sql- Tests Row Level Security policies - ✅
triggers.test.sql- Tests database triggers - ✅
functions.test.sql- Tests database functions - ✅
README.md- Database testing documentation
Run with:
yarn test:dbLocation: packages/api/src/__tests__/
Files Created:
- ✅
router.test.ts- Comprehensive tRPC router tests - ✅
helpers.ts- Test helper functions - ✅
setup.ts- Test environment setup - ✅
README_TESTING.md- API testing documentation
Mock Files:
- ✅
packages/api/src/__mocks__/supabase.ts- Mock Supabase client
Configuration:
- ✅
packages/api/vitest.config.ts- Vitest configuration
Run with:
yarn test:api
# or
cd packages/api && yarn testFiles Created:
- ✅
TESTING_PLAN.md- Comprehensive testing strategy and plan - ✅
TESTING_QUICKSTART.md- Quick start guide for testing - ✅
TESTING_SUMMARY.md- This file
Updated Files:
-
✅
package.json- Added test scripts:test- Run all teststest:db- Run database teststest:api- Run API teststest:watch- Watch modetest:coverage- Coverage report
-
✅
packages/api/package.json- Added:- Vitest dependencies (
vitest,@vitest/ui,@vitest/coverage-v8) - Test scripts (
test,test:watch,test:ui,test:coverage)
- Vitest dependencies (
Fixed:
- ✅
packages/api/src/index.ts- FixeduserCreatemutation to useinput.nameinstead ofinput
- ✅ Schema structure (tables, columns, types, constraints)
- ✅ Indexes
- ✅ Row Level Security policies
- ✅ Database triggers
- ✅ Database functions
- ✅
helloprocedure (with and without name) - ✅
userListprocedure (success and error cases) - ✅
userByIdprocedure (found, not found) - ✅
userCreateprocedure (success and error cases) - ✅
testAuthprocedure (authentication flow)
-
Install dependencies:
yarn install
-
Start Supabase (if not running):
yarn supabase:start
-
Run tests to verify setup:
# Database tests yarn test:db # API tests yarn test:api
-
Add more tests as needed:
- Add database tests for new tables/columns
- Add API tests for new tRPC procedures
- Add integration tests for end-to-end flows
-
Set up CI/CD:
- See
TESTING_PLAN.mdfor GitHub Actions example - Configure test runs in your CI/CD pipeline
- See
.
├── supabase/
│ └── tests/
│ └── database/
│ ├── schema.test.sql
│ ├── rls.test.sql
│ ├── triggers.test.sql
│ ├── functions.test.sql
│ └── README.md
├── packages/
│ └── api/
│ ├── vitest.config.ts
│ ├── README_TESTING.md
│ └── src/
│ ├── __tests__/
│ │ ├── router.test.ts
│ │ ├── helpers.ts
│ │ └── setup.ts
│ └── __mocks__/
│ └── supabase.ts
├── TESTING_PLAN.md
├── TESTING_QUICKSTART.md
└── TESTING_SUMMARY.md
yarn test # Run all tests
yarn test:db # Run database tests
yarn test:api # Run API tests
yarn test:watch # Watch mode
yarn test:coverage # Coverage reportcd packages/api
yarn test # Run tests once
yarn test:watch # Watch mode
yarn test:ui # Interactive UI
yarn test:coverage # Coverage report- Full Testing Plan - Complete testing strategy
- Quick Start Guide - Get started quickly
- Database Tests README - Database testing details
- API Tests README - API testing details
If you encounter issues:
- Check the troubleshooting sections in the documentation
- Verify all dependencies are installed
- Ensure Supabase is running for database tests
- Check environment variables are set correctly