VibeCode Testing Guide
Framework
- Jest with ts-jest transform
- Test files:
*.test.ts, *.test.tsx
- Locations:
tests/unit/, tests/integration/, tests/
Running Tests
# Full suite (ALWAYS use --maxWorkers=2)
npx jest --maxWorkers=2 --passWithNoTests
# Single file
npx jest --maxWorkers=2 path/to/file.test.ts
# With coverage
npx jest --maxWorkers=2 --coverage
# Pattern match
npx jest --maxWorkers=2 --testPathPattern="auth"
Test Patterns
import { describe, it, expect, jest, beforeEach } from '@jest/globals';
describe('ModuleName', () => {
beforeEach(() => {
jest.clearAllMocks();
});
describe('functionName', () => {
it('should handle normal input correctly', () => {
// arrange, act, assert
});
it('should throw on invalid input', () => {
expect(() => fn(null)).toThrow();
});
});
});
Mock Patterns
- Mock next-auth:
jest.mock('next-auth', () => ({ getServerSession: jest.fn() }))
- Mock prisma:
jest.mock('@/lib/prisma', () => ({ prisma: { user: { findUnique: jest.fn() } } }))
- Mock env vars:
process.env.X = 'value' in beforeEach, cleanup in afterEach
- Mock fetch:
global.fetch = jest.fn().mockResolvedValue({ json: () => ({}) })
Known Pre-Existing Failures (do NOT fix, do NOT block on)
tests/feature-audit/issue-1527.test.ts
tests/unit/components/AppNavigation.test.tsx
tests/unit/lib/auth-password.test.ts (2 failures)
- Several page-level tests with route-metrics issues
Critical Rules
- NEVER use
--maxWorkers > 2 (OOM, exit 137)
- NEVER delete tests to make suite pass
- After deleting source files, grep for orphaned test imports
- Mock external dependencies, never make real API/DB calls
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: ryanmaclean-vibecode-webgui-testing-guide3description: VibeCode Testing Guide4---56# VibeCode Testing Guide78## Framework9- Jest with ts-jest transform10- Test files: `*.test.ts`, `*.test.tsx`11- Locations: `tests/unit/`, `tests/integration/`, `tests/`1213## Running Tests14```bash15# Full suite (ALWAYS use --maxWorkers=2)16npx jest --maxWorkers=2 --passWithNoTests1718# Single file19npx jest --maxWorkers=2 path/to/file.test.ts2021# With coverage22npx jest --maxWorkers=2 --coverage2324# Pattern match25npx jest --maxWorkers=2 --testPathPattern="auth"26```2728## Test Patterns29```typescript30import { describe, it, expect, jest, beforeEach } from '@jest/globals';3132describe('ModuleName', () => {33 beforeEach(() => {34 jest.clearAllMocks();35 });3637 describe('functionName', () => {38 it('should handle normal input correctly', () => {39 // arrange, act, assert40 });4142 it('should throw on invalid input', () => {43 expect(() => fn(null)).toThrow();44 });45 });46});47```4849## Mock Patterns50- Mock next-auth: `jest.mock('next-auth', () => ({ getServerSession: jest.fn() }))`51- Mock prisma: `jest.mock('@/lib/prisma', () => ({ prisma: { user: { findUnique: jest.fn() } } }))`52- Mock env vars: `process.env.X = 'value'` in beforeEach, cleanup in afterEach53- Mock fetch: `global.fetch = jest.fn().mockResolvedValue({ json: () => ({}) })`5455## Known Pre-Existing Failures (do NOT fix, do NOT block on)56- `tests/feature-audit/issue-1527.test.ts`57- `tests/unit/components/AppNavigation.test.tsx`58- `tests/unit/lib/auth-password.test.ts` (2 failures)59- Several page-level tests with route-metrics issues6061## Critical Rules62- NEVER use `--maxWorkers` > 2 (OOM, exit 137)63- NEVER delete tests to make suite pass64- After deleting source files, grep for orphaned test imports65- Mock external dependencies, never make real API/DB calls6667---68> Converted and distributed by [TomeVault](https://tomevault.io/claim/ryanmaclean) — claim your Tome and manage your conversions.69<!-- tomevault:4.0:skill_md:2026-04-13 -->