en un clic
running-tests
// Use when running tests in the Nango monorepo - knows unit vs integration configs, vitest commands, Docker setup, and common test patterns
// Use when running tests in the Nango monorepo - knows unit vs integration configs, vitest commands, Docker setup, and common test patterns
Use when adding or editing Nango database migrations - covers migration directory selection, timestamped .cjs naming, matching recent migration style, down migration decisions, and foreign key ON DELETE conventions.
Use when creating new agent skills or improving existing ones - ensures skills are discoverable, scannable, and effective through proper structure, discovery optimization, and real examples
Use when modifying or visually debugging Nango frontend UI, including packages/webapp, packages/connect-ui, browser interactions, screenshots, and visual regressions. Prefer browser-controlled or headless Playwright checks; use Peekaboo only for native macOS, visible-browser, or Accessibility tree inspection.
Use when adding documentation for a new Nango integration - creates main page, setup guide, and updates docs.json and providers.yaml following established patterns
Use when running the Nango application locally for development and browser testing - covers Docker services, dev commands, service URLs, and troubleshooting startup issues
Use when building the Nango monorepo or verifying TypeScript compilation - covers build commands, project references, common tsc errors, and package dependency order
| name | running-tests |
| description | Use when running tests in the Nango monorepo - knows unit vs integration configs, vitest commands, Docker setup, and common test patterns |
Nango uses Vitest with three separate configs for unit, integration, and CLI tests. Getting the config wrong silently runs zero tests.
| Type | Command | File pattern |
|---|---|---|
| Unit | npm run test:unit | *.unit.test.ts |
| Integration | npm run test:integration | *.integration.test.ts |
| CLI | npm run test:cli | *.unit.cli-test.ts |
| All | npm run test | all patterns |
# Single integration test file
npm run test:integration -- packages/server/lib/controllers/v1/team/getTeam.integration.test.ts
# Single unit test file
npm run test:unit -- packages/server/lib/authz/permissions.unit.test.ts
# Pattern match
npm run test:integration -- -t "should be protected"
All commands run from the repo root.
Always run npm install first — after pulling changes, switching branches, or in a fresh worktree. Missing deps cause import errors that look like code issues.
tests/setup.ts) starts PostgreSQL, Elasticsearch, ActiveMQ, and Redis via testcontainersfileParallelism: false, singleFork: true)FLAG_AUTH_ROLES_ENABLED=true, timezone UTCimport { afterAll, beforeAll, describe, expect, it } from 'vitest';
import { seeders } from '@nangohq/shared';
import { runServer, shouldBeProtected, shouldRequireQueryEnv } from '../../../../utils/tests.js';
const route = '/api/v1/endpoint';
let api: Awaited<ReturnType<typeof runServer>>;
describe(`GET ${route}`, () => {
beforeAll(async () => {
api = await runServer(); // Starts Express + runs all migrations
});
afterAll(() => { api.server.close(); });
it('should be protected', async () => {
const res = await api.fetch(route, { method: 'GET', query: { env: 'dev' } });
shouldBeProtected(res);
});
});
Key utilities (packages/server/lib/utils/tests.ts):
runServer() — starts Express with DB migrationsshouldBeProtected(res) — asserts 401shouldRequireQueryEnv(res) — asserts 400 missing envauthenticateUser(api, user, password) — returns session cookie (use for endpoints needing res.locals.user)isSuccess(json) / isError(json) — response type guardsSeeders (@nangohq/shared):
seeders.seedAccountEnvAndUser() — creates account, environment, user, secret keyAvailable in all tests via tests/setupFiles.ts:
toBeIsoDate(), toBeIsoDateTimezone(), toBeUUID(), toBeSha256()toBeWithinMs(expected, toleranceMs)| Mistake | Symptom | Fix |
|---|---|---|
| Wrong config for integration tests | 0 tests found | Use npm run test:integration not npm run test:unit |
| Using bearer token for session endpoints | 401 errors | Use authenticateUser() + session cookie |
| Running from package dir | Config not found | Always run from repo root |
| Docker not running | Connection refused | Integration tests need Docker for testcontainers |
Missing query: { env: 'dev' } | 400 invalid query | Most endpoints require env query param |