| name | run-tests |
| description | Run the test suite for the Cartridge Controller monorepo. Use when validating changes, before committing, or when asked to run tests. |
Run Tests
Quick Reference
| Command | Purpose | Duration |
|---|
pnpm lint:check | Lint + format check | ~30s |
pnpm test | Unit tests | ~1-2min |
pnpm test:ci | Unit tests with coverage | ~2-3min |
pnpm test:storybook | Visual regression tests | ~5-10min |
pnpm build | Full build (includes type check) | ~2-3min |
pnpm e2e | End-to-end tests | ~5-10min |
Test Types
1. Linting and Formatting
Fastest check - always run before committing:
pnpm lint:check
This runs:
- ESLint for code quality
- Prettier for formatting
To auto-fix issues:
pnpm format
2. Unit Tests
Tests the keychain package:
pnpm test
pnpm test:ci
pnpm keychain test -- --testPathPattern="connection"
Test files are located in:
packages/keychain/src/**/*.test.ts
packages/controller/src/__tests__/
3. Storybook Visual Regression Tests
Tests UI components for visual changes:
pnpm test:storybook
pnpm test:storybook:update
Snapshots are stored in:
packages/keychain/__image_snapshots__/
4. Build (Type Checking)
TypeScript compilation catches type errors:
pnpm build
This also validates that all packages compile correctly.
5. End-to-End Tests
Full integration tests with Playwright:
pnpm e2e
pnpm e2e:ui
E2E tests are in:
CI Equivalence
To mirror what CI runs, execute in order:
pnpm lint:check
pnpm build
pnpm test:ci
pnpm test:storybook
Interpreting Results
Test Failures
pnpm keychain test -- --verbose --testNamePattern="failing test name"
Snapshot Failures
If Storybook tests fail with visual differences:
- Review the diff images in
packages/keychain/__image_snapshots__/__diff_output__/
- If changes are intentional:
pnpm test:storybook:update
- If changes are unintentional: fix the component
Type Errors
pnpm controller build:deps
pnpm keychain build
Package-Specific Testing
pnpm controller test
pnpm keychain test
pnpm keychain test -- --watch
Common Issues
"Cannot find module" errors
pnpm clean && pnpm i && pnpm build:deps
Storybook tests timeout
Ensure the Storybook server is not already running on port 6006.
E2E tests fail to start
Ensure dev servers are running:
pnpm dev
pnpm e2e
Pre-Commit Verification
The git pre-commit hook automatically runs:
pnpm run format --ui stream
pnpm run lint:check --ui stream
This ensures basic quality before every commit.