Index of every page on this site: llms.txt
All skills
nangohq avatar

/running-tests

@0c949ea
by Nangonangohq/nango13k stars
1,543
Run it yourself

Use when running tests in the Nango monorepo - knows unit vs integration configs, vitest commands, Docker setup, and common test patterns

Use this Skill: https://skilld.dev/gh/nangohq/nango/running-tests

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈38 tokens for metadata: the name and description. ≈840 when used: this file.

Description uses 1.9% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈153 characters, or 1.9%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Running Tests in Nango

Overview

Nango uses Vitest with three separate configs for unit, integration, and CLI tests. Getting the config wrong silently runs zero tests.

Quick Reference

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

Running Specific Tests

# 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.

Before Running Tests

Always install dependencies first — npm install after pulling changes or switching branches, npm ci in a fresh worktree. Missing deps cause import errors that look like code issues.

Integration Test Requirements

  • Docker required: Global setup (tests/setup.ts) starts PostgreSQL, Elasticsearch, ActiveMQ, and Redis via testcontainers
  • Tests run sequentially (fileParallelism: false, singleFork: true)
  • Timeout: 20 seconds per test
  • Environment: FLAG_AUTH_ROLES_ENABLED=true, timezone UTC

Writing Integration Tests

import { 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 migrations
  • shouldBeProtected(res) — asserts 401
  • shouldRequireQueryEnv(res) — asserts 400 missing env
  • authenticateUser(api, user, password) — returns session cookie (use for endpoints needing res.locals.user)
  • isSuccess(json) / isError(json) — response type guards

Seeders (@nangohq/shared):

  • seeders.seedAccountEnvAndUser() — creates account, environment, user, secret key

Custom Matchers

Available in all tests via tests/setupFiles.ts:

  • toBeIsoDate(), toBeIsoDateTimezone(), toBeUUID(), toBeSha256()
  • toBeWithinMs(expected, toleranceMs)

Common Mistakes

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

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts3mo3 checks · Risk SAFE
  • Gen Agent Trust Hub3mo

    This skill provides documentation and command references for running unit, integration, and CLI tests within the Nango monorepo. It contains standard development workflows and no security issues were detected.

  • Socket3mo

    No alerts

  • Snyk3mo

    Risk: LOW · No issues

Signed by skilld at 0c949ea. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 4 weeks ago

README badge

README badge for nangohq/nango/running-tests