Emulate Seed Configs
Generate and manage seed configs for emulate (Apache-2.0) — Vercel Labs' stateful API emulation tool. Each category has individual rule files in rules/ loaded on-demand.
Paired agent: This skill pairs with the emulate-engineer subagent (subagent_type: "ork:emulate-engineer"). When a task involves generating a full emulate config from scratch, webhook HMAC setup, CI pipeline integration, or parallel-worker port isolation, spawn the agent rather than handling it inline — it has the full 13-emulator service-port matrix and seed-rules in context.
Not mocks. Emulate provides full state machines with cascading deletes, cursor pagination, webhook delivery, and HMAC signature verification. Create a PR via the API and it appears in GET /repos/:owner/:repo/pulls. Delete a repo and its issues, PRs, and webhooks cascade-delete.
New in 2026-04 (emulate 0.4.x)
- Modular
@emulators/* packages — each service is its own package (@emulators/github, @emulators/stripe, etc.); top-level emulate re-exports createEmulator and the CLI.
- 4 new services (12 total):
mongoatlas:4007, okta:4008, resend:4009, stripe:4010 with drop-in seed YAML blocks.
- Resend local inbox —
GET http://localhost:4009/inbox returns captured emails for assertions without hitting a real provider.
- Stripe hosted checkout — real session redirect flow +
checkout.session.completed/expired webhook delivery, suitable for E2E payment tests.
- MongoDB Atlas — Admin API v2 (projects/clusters/DB users) + Data API v1 with full CRUD + aggregate.
- Okta OIDC — full discovery, JWKS,
authorize/token/userinfo/revoke/introspect plus Users/Groups/Apps CRUD.
- Entra / Apple / Slack expansions (v0.4.0) — PKCE + refresh rotation (Entra), RS256 JWKS (Apple), OAuth v2 consent UI (Slack).
@emulators/adapter-next — catch-all Next.js route handler runs emulators on the same origin as the app; fixes OAuth callback URL drift on Vercel preview deploys.
Auto-Discovery (M125 #4)
scripts/auto-discover.sh scans the project's package.json, matches deps against references/dep-to-emulator-map.json, and either reports the matches or writes emulate.config.yaml. Three modes:
| Mode |
Behavior |
| (default) |
Report matched deps + emulator union on stderr; do not write |
--json |
Emit machine-readable JSON instead of human report |
--apply |
Write emulate.config.yaml (refuses to overwrite without --force) |
$ bash scripts/auto-discover.sh
/ork:emulate-seed --auto — scanning /path/to/package.json
Detected:
@octokit/rest → github · Any GitHub API client
next-auth → google-oauth, apple-auth, microsoft-entra · Default OAuth providers
stripe → stripe
@vercel/blob → aws · @vercel/blob is S3-compatible
Union: apple-auth, aws, github, google-oauth, microsoft-entra, stripe
$ bash scripts/auto-discover.sh --apply
…
✓ Wrote /path/to/emulate.config.yaml with 6 service(s)
Multi-emulator deps default to all reasonable providers; the user prunes the YAML afterwards. Unmapped deps are silently skipped — extending coverage is a docs PR (edit references/dep-to-emulator-map.json), not a code change.
/ork:dev reads the resulting emulate.config.yaml at boot — see src/skills/dev/scripts/boot.sh.
Quick Reference
| Category |
Rules |
Impact |
When to Use |
| Seed Config |
1 |
HIGH |
Setting up emulate.config.yaml for test environments |
| Service Selection |
1 |
MEDIUM |
Choosing GitHub/Vercel/Google for your tests |
| Webhook Setup |
1 |
MEDIUM |
Testing webhook delivery with HMAC verification |
| Parallel CI |
1 |
HIGH |
Running tests in parallel without port collisions |
| Auth Tokens |
1 |
MEDIUM |
Seeding tokens mapped to emulated users |
Total: 5 rules across 5 categories
Quick Start
# Install (packages published under @emulators/* scope)
npm install --save-dev emulate
# Start all services
npx emulate
# Start specific services with seed data
npx emulate --service github,stripe --seed ./emulate.config.yaml
# Generate a starter config
npx emulate init --service github
Services (0.10.0 — 14 emulators)
New across releases:
- 0.5.0 — added Clerk, MongoDB Atlas, Stripe, Resend, and Okta emulators; portless integration (embedded emulators without dedicated ports); Google OAuth
hd claim support; Stripe Checkout + Resend magic link examples; AWS S3 emulator now matches the official SDK wire format.
- 0.6.0 — expanded Slack (OAuth v2 consent UI, conversations/reactions).
- 0.6.1 — Vercel Blob store.
- 0.7.0 — added Linear (13th provider): stateful orgs/teams/issues/cycles + webhooks.
- 0.8.0 — added Twilio (14th provider): accounts, phone numbers, messages, calls, conversations, messaging services, Verify flows, and simulator endpoints, with a Next.js SMS-verification example.
- 0.9.0 — added a Nuxt emulator adapter (alongside the Next.js adapter); provider count unchanged.
- 0.10.0 — stateful GitHub repository contents and commit history (
GET /repos/:owner/:repo/readme, GET/PUT/DELETE /repos/:owner/:repo/contents/:path where writes produce real commits, GET /repos/:owner/:repo/commits, and GET /repositories/:id by numeric ID); a readonly generatedSecrets array on the Emulator object with a new exported GeneratedSecret type; GitHub App JWT verification now accepts PKCS#8 as well as PKCS#1 keys. Provider count unchanged.
All backwards-compatible, with one behaviour change worth knowing: 0.10.0 switched
Stripe webhook deliveries to Stripe's own Stripe-Signature header format. Upstream
files it under bug fixes rather than breaking changes, but a test asserting the old
GitHub-style sha256= header on a Stripe delivery will now fail. See Webhook Delivery
below for both formats.
| Service |
Default Port |
Coverage |
| Vercel |
:4000 |
Projects, deployments, domains, env vars, teams |
| GitHub |
:4001 |
Repos, PRs, issues, comments, reviews, Actions, webhooks, orgs, teams |
| Google OAuth |
:4002 |
OAuth 2.0 authorize, token exchange, userinfo |
| Slack |
:4003 |
Chat, conversations, users, reactions, OAuth v2 with consent UI |
| Apple Auth |
:4004 |
Sign in with Apple — OIDC discovery, JWKS (RS256), auth flow, token exchange |
| Microsoft Entra |
:4005 |
OAuth 2.0/OIDC v2.0, authorization code + PKCE, refresh token rotation, v1 token endpoint, Graph /users/{id} |
| AWS |
:4006 |
S3 buckets, SQS queues, IAM users/roles, STS identity |
| MongoDB Atlas (0.4+) |
:4007 |
Admin API v2 (projects, clusters, DB users) + Data API v1 (full CRUD + aggregate) |
| Okta (0.4+) |
:4008 |
OIDC discovery, JWKS, authorize/token/userinfo/revoke/introspect, Users/Groups/Apps CRUD |
| Resend (0.4+) |
:4009 |
Send + batch (100/req), list/retrieve/cancel, domains, API keys, audiences, contacts, local inbox (GET /inbox) |
| Stripe (0.4+) |
:4010 |
Customers, payment methods, customer sessions, payment intents, charges, products, prices, hosted checkout session w/ webhook delivery |
| Clerk (0.5+) |
(on-demand) |
Users, sessions, organizations |
| Linear (0.7+) |
(on-demand) |
Orgs, teams, issues, cycles, webhooks |
| Twilio (0.8+) |
(on-demand) |
Accounts, phone numbers, messages, calls, conversations, messaging services, Verify flows, simulator endpoints |
See references/api-coverage.md for full endpoint lists.
Next.js Adapter (0.4+) — @emulators/adapter-next
Runs emulators on the same origin as your Next.js app via a catch-all route handler. Fixes the OAuth callback URL drift problem on Vercel preview deploys — no more http://localhost:4001 redirect mismatches.
// next.config.js
const { withEmulate } = require('@emulators/adapter-next')
module.exports = withEmulate({ /* your next config */ })
// app/api/[...emulate]/route.ts
import { createEmulateHandler } from '@emulators/adapter-next'
export const { GET, POST } = createEmulateHandler({
services: ['github', 'stripe', 'resend'],
persistence: { /* load(), save() or built-in filePersistence */ },
})
Seed Config Structure
A seed config pre-populates the emulator with tokens, users, repos, and projects so tests start from a known state.
# emulate.config.yaml
tokens:
dev_token:
login: yonatangross
scopes: [repo, workflow, admin:org]
ci_token:
login: ci-bot
scopes: [repo]
github:
users:
- login: yonatangross
name: Yonatan Gross
- login: ci-bot
name: CI Bot
repos:
- owner: yonatangross
name: my-project
private: false
default_branch: main
topics: [typescript, testing]
vercel:
users:
- username: yonatangross
email: yonaigross@gmail.com
projects:
- name: my-docs
framework: next
# NEW in 0.4.x — drop-in seed blocks
okta:
users:
- login: alice@example.com
firstName: Alice
lastName: Smith
groups: [{ name: Everyone }, { name: Admins }]
apps: [{ name: My Web App }]
authorization_servers:
- name: default
audiences: ["api://default"]
resend:
domains: [{ name: example.com }]
api_keys: [{ name: default }]
# In tests: GET http://localhost:4009/inbox to assert captured emails
stripe:
customers:
- name: Test Customer
email: customer@example.com
products: [{ name: Pro Plan }, { name: Starter Plan }]
prices:
- { product: Pro Plan, unit_amount: 4900, currency: usd, recurring: { interval: month } }
- { product: Starter Plan, unit_amount: 1900, currency: usd, recurring: { interval: month } }
# Webhook delivery fires on checkout.session.completed / expired
mongoatlas:
projects: [{ name: my-project }]
clusters: [{ project: my-project, name: my-cluster }]
database_users: [{ project: my-project, username: app-user }]
See rules/seed-config.md for full schema and best practices.
Programmatic SDK
Service packages live under the @emulators/* scope (e.g., @emulators/github, @emulators/stripe). The programmatic API (createEmulator) is exported from the top-level emulate package.
import { createEmulator } from 'emulate'
const github = await createEmulator({ service: 'github', port: 4001 })
// github.url -> 'http://localhost:4001'
// State is real — create a PR and it appears in the list
const res = await fetch(`${github.url}/repos/org/repo/pulls`, {
method: 'POST',
headers: { Authorization: 'Bearer dev_token' },
body: JSON.stringify({ title: 'Test PR', head: 'feature', base: 'main' })
})
const prs = await fetch(`${github.url}/repos/org/repo/pulls`)
// -> includes the PR we just created
// Auto-generated credentials (0.10.0+): readonly GeneratedSecret[], each
// { service, kind, id, label, value }. A GitHub App emulator, for example,
// generates its own RSA key rather than making you supply one.
github.generatedSecrets
// Cleanup
github.reset() // Synchronous state wipe
await github.close() // Shut down server
seed here is a parsed object, not a path. Only the CLI --seed flag takes a filename.
For multi-service setup, lifecycle hooks, and the Vitest/Jest wiring, see
references/upstream.md. For the ork-side corrections to that API, see
references/ork-delta.md.
Webhook Delivery
Emulate delivers real webhooks with HMAC-SHA256 signatures when state changes. The
signature FORMAT is per-provider, so one generic verifier does not cover every service.
GitHub-format headers remain the default; Stripe has used its own format since 0.10.0.
import crypto from 'crypto'
// GitHub format (the default for most services): sha256=<hmac over the raw body>
function verifyWebhook(payload: string, signature: string, secret: string): boolean {
const expected = 'sha256=' + crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex')
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))
}
// Stripe format, as of emulate 0.10.0: Stripe-Signature: t=<timestamp>,v1=<hmac>,
// where the HMAC covers `<timestamp>.<raw body>`, NOT the body alone. Verifying a
// Stripe delivery with the GitHub helper above fails on both counts.
function verifyStripeWebhook(rawBody: string, header: string, secret: string): boolean {
const parts = Object.fromEntries(header.split(',').map((kv) => kv.split('=')))
const expected = crypto
.createHmac('sha256', secret)
.update(`${parts.t}.${rawBody}`)
.digest('hex')
return crypto.timingSafeEqual(Buffer.from(parts.v1), Buffer.from(expected))
}
See rules/webhook-setup.md for webhook receiver patterns.
CI Integration
# .github/workflows/test.yml
jobs:
test:
steps:
- uses: actions/checkout@v4
- name: Start emulate
run: npx emulate --service github --seed .emulate/ci.yaml &
- name: Wait for emulate
run: sleep 2
- name: Run tests
run: npm test
env:
GITHUB_API_BASE: http://localhost:4001
VERCEL_API_BASE: http://localhost:4000
Parallel Test Execution
Each test worker gets its own port to avoid race conditions:
// vitest.config.ts
const workerPort = 4001 + parseInt(process.env.VITEST_WORKER_ID || '0')
See rules/parallel-ci.md for full parallel isolation patterns.
Decision Matrix
| Tool |
When to Use |
Stateful? |
Platforms |
| emulate (FIRST CHOICE) |
GitHub/Vercel/Google/Slack/Apple/Entra/AWS/Okta/Resend/Stripe/MongoDB/Clerk/Linear testing |
YES |
All 13 services |
| Pact |
Contract verification between services |
No |
Any |
| MSW |
In-browser/Node HTTP mocking |
No |
Any |
| Nock |
Node.js HTTP intercept |
No |
Any |
| WireMock |
HTTP stub server |
Partial |
Any |
Use emulate when:
- Testing code that calls GitHub, Vercel, Google, Slack, Apple, Entra, AWS, Okta, Resend, Stripe, MongoDB Atlas, Clerk, or Linear
- You need state persistence across multiple API calls in a test
- You want webhook delivery with real HMAC signatures (GitHub, Stripe)
- You need cascading side-effects (delete repo -> PRs cascade-delete)
- You need to assert on sent emails without hitting a real provider (Resend local
/inbox)
- You need hosted Stripe checkout sessions with real redirect flow in tests
Use MSW/Nock when:
- Mocking arbitrary HTTP APIs not covered by emulate
- You need in-browser interception (MSW)
- Tests only need single request/response pairs
Upstream coverage (do not restate)
This skill is a wrap plus our delta. emulate ships its own per-service reference docs;
copying them here only produces something that goes stale on the next release. If a
topic below comes up, read the first-party source, not a paraphrase.
| Topic |
First-party source |
Programmatic API (createEmulator, url, reset(), close()), Vitest/Jest wiring, config auto-detection order, token fallback |
references/upstream.md (synced from vercel-labs/emulate, skills/emulate/SKILL.md) |
| GitHub endpoint recipes, GitHub App JWT seeding, Octokit and Auth.js base-URL wiring, GitHub OAuth flow |
https://github.com/vercel-labs/emulate/blob/main/skills/github/SKILL.md |
Google OIDC discovery, JWKS, authorize/token/userinfo/revoke, PKCE, google-auth-library, Passport, openid-client |
https://github.com/vercel-labs/emulate/blob/main/skills/google/SKILL.md |
| Vercel endpoint recipes, cursor pagination, team scoping, integration OAuth flow |
https://github.com/vercel-labs/emulate/blob/main/skills/vercel/SKILL.md |
| Every other emulator (Slack, Apple, Entra, AWS, Okta, Resend, Stripe, MongoDB Atlas, Clerk, Linear, Twilio) |
https://github.com/vercel-labs/emulate/tree/main/skills |
What stays ours: references/ork-delta.md (the corrections and house conventions that
are not in any vendor doc), references/cli-reference.md, references/api-coverage.md,
references/dep-to-emulator-map.json, scripts/auto-discover.sh, and everything in rules/.
Read references/ork-delta.md before copying any snippet out of a vendor doc. It records
the two API facts vendor prose does not spell out (the exported factory is createEmulator,
and seed in the programmatic options is an object rather than a path) plus the
*_API_BASE env-var convention this repo uses instead of the vendor's *_EMULATOR_URL.
Related Skills
testing-integration — Integration test patterns (emulate as first choice for API tests)
testing-e2e — End-to-end test patterns with emulated backends
testing-unit — Unit test patterns (use emulate for API-dependent units)
security-patterns — Auth token patterns (emulate token seeding)
CLI Reference
See references/cli-reference.md for all CLI flags and commands.
1---2name: emulate-seed3description: Generate emulate seed configs for stateful API emulation. Wraps Vercel's emulate tool for GitHub, Vercel, Google OAuth, Slack, Apple Auth, Microsoft Entra, AWS, Okta, Clerk, Resend, Stripe, and MongoDB Atlas APIs — full state machines, not mocks. Use when setting up test environments, CI pipelines, integration tests, or offline development.4---5
6# Emulate Seed Configs
7
8Generate and manage seed configs for [emulate](https://github.com/vercel-labs/emulate) (Apache-2.0) — Vercel Labs' stateful API emulation tool. Each category has individual rule files in `rules/` loaded on-demand.
9
10> **Paired agent:** This skill pairs with the [`emulate-engineer`](../../agents/emulate-engineer.md) subagent (`subagent_type: "ork:emulate-engineer"`). When a task involves generating a full emulate config from scratch, webhook HMAC setup, CI pipeline integration, or parallel-worker port isolation, spawn the agent rather than handling it inline — it has the full 13-emulator service-port matrix and seed-rules in context.
11
12**Not mocks.** Emulate provides full state machines with cascading deletes, cursor pagination, webhook delivery, and HMAC signature verification. Create a PR via the API and it appears in `GET /repos/:owner/:repo/pulls`. Delete a repo and its issues, PRs, and webhooks cascade-delete.
13
14## New in 2026-04 (emulate 0.4.x)
15
16- **Modular `@emulators/*` packages** — each service is its own package (`@emulators/github`, `@emulators/stripe`, etc.); top-level `emulate` re-exports `createEmulator` and the CLI.
17- **4 new services** (12 total): `mongoatlas:4007`, `okta:4008`, `resend:4009`, `stripe:4010` with drop-in seed YAML blocks.
18- **Resend local inbox** — `GET http://localhost:4009/inbox` returns captured emails for assertions without hitting a real provider.
19- **Stripe hosted checkout** — real session redirect flow + `checkout.session.completed`/`expired` webhook delivery, suitable for E2E payment tests.
20- **MongoDB Atlas** — Admin API v2 (projects/clusters/DB users) + Data API v1 with full CRUD + aggregate.
21- **Okta OIDC** — full discovery, JWKS, `authorize/token/userinfo/revoke/introspect` plus Users/Groups/Apps CRUD.
22- **Entra / Apple / Slack expansions (v0.4.0)** — PKCE + refresh rotation (Entra), RS256 JWKS (Apple), OAuth v2 consent UI (Slack).
23- **`@emulators/adapter-next`** — catch-all Next.js route handler runs emulators on the same origin as the app; fixes OAuth callback URL drift on Vercel preview deploys.
24
25## Auto-Discovery (M125 #4)
26
27`scripts/auto-discover.sh` scans the project's `package.json`, matches deps against `references/dep-to-emulator-map.json`, and either reports the matches or writes `emulate.config.yaml`. Three modes:
28
29| Mode | Behavior |
30|---|---|
31| (default) | Report matched deps + emulator union on stderr; do not write |
32| `--json` | Emit machine-readable JSON instead of human report |
33| `--apply` | Write `emulate.config.yaml` (refuses to overwrite without `--force`) |
34
35```bash
36$ bash scripts/auto-discover.sh
37/ork:emulate-seed --auto — scanning /path/to/package.json
38
39Detected:
40 @octokit/rest → github · Any GitHub API client
41 next-auth → google-oauth, apple-auth, microsoft-entra · Default OAuth providers
42 stripe → stripe
43 @vercel/blob → aws · @vercel/blob is S3-compatible
44
45Union: apple-auth, aws, github, google-oauth, microsoft-entra, stripe
46
47$ bash scripts/auto-discover.sh --apply
48…
49✓ Wrote /path/to/emulate.config.yaml with 6 service(s)
50```
51
52Multi-emulator deps default to all reasonable providers; the user prunes the YAML afterwards. Unmapped deps are silently skipped — extending coverage is a docs PR (edit `references/dep-to-emulator-map.json`), not a code change.
53
54`/ork:dev` reads the resulting `emulate.config.yaml` at boot — see `src/skills/dev/scripts/boot.sh`.
55
56## Quick Reference
57
58| Category | Rules | Impact | When to Use |
59|----------|-------|--------|-------------|
60| [Seed Config](#seed-config) | 1 | HIGH | Setting up emulate.config.yaml for test environments |
61| [Service Selection](#service-selection) | 1 | MEDIUM | Choosing GitHub/Vercel/Google for your tests |
62| [Webhook Setup](#webhook-setup) | 1 | MEDIUM | Testing webhook delivery with HMAC verification |
63| [Parallel CI](#parallel-ci) | 1 | HIGH | Running tests in parallel without port collisions |
64| [Auth Tokens](#auth-tokens) | 1 | MEDIUM | Seeding tokens mapped to emulated users |
65
66**Total: 5 rules across 5 categories**
67
68## Quick Start
69
70```bash
71# Install (packages published under @emulators/* scope)
72npm install --save-dev emulate
73
74# Start all services
75npx emulate
76
77# Start specific services with seed data
78npx emulate --service github,stripe --seed ./emulate.config.yaml
79
80# Generate a starter config
81npx emulate init --service github
82```
83
84## Services (0.10.0 — 14 emulators)
85
86> **New across releases:**
87> - **0.5.0** — added Clerk, MongoDB Atlas, Stripe, Resend, and Okta emulators; portless integration (embedded emulators without dedicated ports); Google OAuth `hd` claim support; Stripe Checkout + Resend magic link examples; AWS S3 emulator now matches the official SDK wire format.
88> - **0.6.0** — expanded Slack (OAuth v2 consent UI, conversations/reactions).
89> - **0.6.1** — Vercel Blob store.
90> - **0.7.0** — added Linear (13th provider): stateful orgs/teams/issues/cycles + webhooks.
91> - **0.8.0** — added Twilio (14th provider): accounts, phone numbers, messages, calls, conversations, messaging services, Verify flows, and simulator endpoints, with a Next.js SMS-verification example.
92> - **0.9.0** — added a Nuxt emulator adapter (alongside the Next.js adapter); provider count unchanged.
93> - **0.10.0** — stateful GitHub repository contents and commit history (`GET /repos/:owner/:repo/readme`, `GET`/`PUT`/`DELETE /repos/:owner/:repo/contents/:path` where writes produce real commits, `GET /repos/:owner/:repo/commits`, and `GET /repositories/:id` by numeric ID); a readonly `generatedSecrets` array on the Emulator object with a new exported `GeneratedSecret` type; GitHub App JWT verification now accepts PKCS#8 as well as PKCS#1 keys. Provider count unchanged.
94>
95> All backwards-compatible, with one behaviour change worth knowing: 0.10.0 switched
96> Stripe webhook deliveries to Stripe's own `Stripe-Signature` header format. Upstream
97> files it under bug fixes rather than breaking changes, but a test asserting the old
98> GitHub-style `sha256=` header on a Stripe delivery will now fail. See Webhook Delivery
99> below for both formats.
100
101| Service | Default Port | Coverage |
102|---------|-------------|----------|
103| **Vercel** | `:4000` | Projects, deployments, domains, env vars, teams |
104| **GitHub** | `:4001` | Repos, PRs, issues, comments, reviews, Actions, webhooks, orgs, teams |
105| **Google OAuth** | `:4002` | OAuth 2.0 authorize, token exchange, userinfo |
106| **Slack** | `:4003` | Chat, conversations, users, reactions, OAuth v2 with consent UI |
107| **Apple Auth** | `:4004` | Sign in with Apple — OIDC discovery, JWKS (RS256), auth flow, token exchange |
108| **Microsoft Entra** | `:4005` | OAuth 2.0/OIDC v2.0, authorization code + PKCE, refresh token rotation, v1 token endpoint, Graph `/users/{id}` |
109| **AWS** | `:4006` | S3 buckets, SQS queues, IAM users/roles, STS identity |
110| **MongoDB Atlas** *(0.4+)* | `:4007` | Admin API v2 (projects, clusters, DB users) + Data API v1 (full CRUD + aggregate) |
111| **Okta** *(0.4+)* | `:4008` | OIDC discovery, JWKS, authorize/token/userinfo/revoke/introspect, Users/Groups/Apps CRUD |
112| **Resend** *(0.4+)* | `:4009` | Send + batch (100/req), list/retrieve/cancel, domains, API keys, audiences, contacts, **local inbox** (`GET /inbox`) |
113| **Stripe** *(0.4+)* | `:4010` | Customers, payment methods, customer sessions, payment intents, charges, products, prices, **hosted checkout session** w/ webhook delivery |
114| **Clerk** *(0.5+)* | (on-demand) | Users, sessions, organizations |
115| **Linear** *(0.7+)* | (on-demand) | Orgs, teams, issues, cycles, webhooks |
116| **Twilio** *(0.8+)* | (on-demand) | Accounts, phone numbers, messages, calls, conversations, messaging services, Verify flows, simulator endpoints |
117
118See `references/api-coverage.md` for full endpoint lists.
119
120### Next.js Adapter (0.4+) — `@emulators/adapter-next`
121
122Runs emulators **on the same origin** as your Next.js app via a catch-all route handler. Fixes the OAuth callback URL drift problem on Vercel preview deploys — no more `http://localhost:4001` redirect mismatches.
123
124```typescript
125// next.config.js
126const { withEmulate } = require('@emulators/adapter-next')
127module.exports = withEmulate({ /* your next config */ })
128
129// app/api/[...emulate]/route.ts
130import { createEmulateHandler } from '@emulators/adapter-next'
131export const { GET, POST } = createEmulateHandler({
132 services: ['github', 'stripe', 'resend'],
133 persistence: { /* load(), save() or built-in filePersistence */ },
134})
135```
136
137## Seed Config Structure
138
139A seed config pre-populates the emulator with tokens, users, repos, and projects so tests start from a known state.
140
141```yaml
142# emulate.config.yaml
143tokens:
144 dev_token:
145 login: yonatangross
146 scopes: [repo, workflow, admin:org]
147 ci_token:
148 login: ci-bot
149 scopes: [repo]
150
151github:
152 users:
153 - login: yonatangross
154 name: Yonatan Gross
155 - login: ci-bot
156 name: CI Bot
157 repos:
158 - owner: yonatangross
159 name: my-project
160 private: false
161 default_branch: main
162 topics: [typescript, testing]
163
164vercel:
165 users:
166 - username: yonatangross
167 email: yonaigross@gmail.com
168 projects:
169 - name: my-docs
170 framework: next
171
172# NEW in 0.4.x — drop-in seed blocks
173okta:
174 users:
175 - login: alice@example.com
176 firstName: Alice
177 lastName: Smith
178 groups: [{ name: Everyone }, { name: Admins }]
179 apps: [{ name: My Web App }]
180 authorization_servers:
181 - name: default
182 audiences: ["api://default"]
183
184resend:
185 domains: [{ name: example.com }]
186 api_keys: [{ name: default }]
187 # In tests: GET http://localhost:4009/inbox to assert captured emails
188
189stripe:
190 customers:
191 - name: Test Customer
192 email: customer@example.com
193 products: [{ name: Pro Plan }, { name: Starter Plan }]
194 prices:
195 - { product: Pro Plan, unit_amount: 4900, currency: usd, recurring: { interval: month } }
196 - { product: Starter Plan, unit_amount: 1900, currency: usd, recurring: { interval: month } }
197 # Webhook delivery fires on checkout.session.completed / expired
198
199mongoatlas:
200 projects: [{ name: my-project }]
201 clusters: [{ project: my-project, name: my-cluster }]
202 database_users: [{ project: my-project, username: app-user }]
203```
204
205See `rules/seed-config.md` for full schema and best practices.
206
207## Programmatic SDK
208
209> Service packages live under the `@emulators/*` scope (e.g., `@emulators/github`, `@emulators/stripe`). The programmatic API (`createEmulator`) is exported from the top-level `emulate` package.
210
211```typescript
212import { createEmulator } from 'emulate'
213
214const github = await createEmulator({ service: 'github', port: 4001 })
215// github.url -> 'http://localhost:4001'
216
217// State is real — create a PR and it appears in the list
218const res = await fetch(`${github.url}/repos/org/repo/pulls`, {
219 method: 'POST',
220 headers: { Authorization: 'Bearer dev_token' },
221 body: JSON.stringify({ title: 'Test PR', head: 'feature', base: 'main' })
222})
223
224const prs = await fetch(`${github.url}/repos/org/repo/pulls`)
225// -> includes the PR we just created
226
227// Auto-generated credentials (0.10.0+): readonly GeneratedSecret[], each
228// { service, kind, id, label, value }. A GitHub App emulator, for example,
229// generates its own RSA key rather than making you supply one.
230github.generatedSecrets
231
232// Cleanup
233github.reset() // Synchronous state wipe
234await github.close() // Shut down server
235```
236
237`seed` here is a parsed object, not a path. Only the CLI `--seed` flag takes a filename.
238For multi-service setup, lifecycle hooks, and the Vitest/Jest wiring, see
239`references/upstream.md`. For the ork-side corrections to that API, see
240`references/ork-delta.md`.
241
242## Webhook Delivery
243
244Emulate delivers real webhooks with HMAC-SHA256 signatures when state changes. The
245signature FORMAT is per-provider, so one generic verifier does not cover every service.
246GitHub-format headers remain the default; Stripe has used its own format since 0.10.0.
247
248```typescript
249import crypto from 'crypto'
250
251// GitHub format (the default for most services): sha256=<hmac over the raw body>
252function verifyWebhook(payload: string, signature: string, secret: string): boolean {
253 const expected = 'sha256=' + crypto
254 .createHmac('sha256', secret)
255 .update(payload)
256 .digest('hex')
257 return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))
258}
259
260// Stripe format, as of emulate 0.10.0: Stripe-Signature: t=<timestamp>,v1=<hmac>,
261// where the HMAC covers `<timestamp>.<raw body>`, NOT the body alone. Verifying a
262// Stripe delivery with the GitHub helper above fails on both counts.
263function verifyStripeWebhook(rawBody: string, header: string, secret: string): boolean {
264 const parts = Object.fromEntries(header.split(',').map((kv) => kv.split('=')))
265 const expected = crypto
266 .createHmac('sha256', secret)
267 .update(`${parts.t}.${rawBody}`)
268 .digest('hex')
269 return crypto.timingSafeEqual(Buffer.from(parts.v1), Buffer.from(expected))
270}
271```
272
273See `rules/webhook-setup.md` for webhook receiver patterns.
274
275## CI Integration
276
277```yaml
278# .github/workflows/test.yml
279jobs:
280 test:
281 steps:
282 - uses: actions/checkout@v4
283 - name: Start emulate
284 run: npx emulate --service github --seed .emulate/ci.yaml &
285 - name: Wait for emulate
286 run: sleep 2
287 - name: Run tests
288 run: npm test
289 env:
290 GITHUB_API_BASE: http://localhost:4001
291 VERCEL_API_BASE: http://localhost:4000
292```
293
294### Parallel Test Execution
295
296Each test worker gets its own port to avoid race conditions:
297
298```typescript
299// vitest.config.ts
300const workerPort = 4001 + parseInt(process.env.VITEST_WORKER_ID || '0')
301```
302
303See `rules/parallel-ci.md` for full parallel isolation patterns.
304
305## Decision Matrix
306
307| Tool | When to Use | Stateful? | Platforms |
308|------|------------|-----------|-----------|
309| **emulate** (FIRST CHOICE) | GitHub/Vercel/Google/Slack/Apple/Entra/AWS/Okta/Resend/Stripe/MongoDB/Clerk/Linear testing | YES | All 13 services |
310| Pact | Contract verification between services | No | Any |
311| MSW | In-browser/Node HTTP mocking | No | Any |
312| Nock | Node.js HTTP intercept | No | Any |
313| WireMock | HTTP stub server | Partial | Any |
314
315**Use emulate when:**
316- Testing code that calls GitHub, Vercel, Google, Slack, Apple, Entra, AWS, Okta, Resend, Stripe, MongoDB Atlas, Clerk, or Linear
317- You need state persistence across multiple API calls in a test
318- You want webhook delivery with real HMAC signatures (GitHub, Stripe)
319- You need cascading side-effects (delete repo -> PRs cascade-delete)
320- You need to assert on sent emails without hitting a real provider (Resend local `/inbox`)
321- You need hosted Stripe checkout sessions with real redirect flow in tests
322
323**Use MSW/Nock when:**
324- Mocking arbitrary HTTP APIs not covered by emulate
325- You need in-browser interception (MSW)
326- Tests only need single request/response pairs
327
328## Upstream coverage (do not restate)
329
330This skill is a wrap plus our delta. emulate ships its own per-service reference docs;
331copying them here only produces something that goes stale on the next release. If a
332topic below comes up, read the first-party source, not a paraphrase.
333
334| Topic | First-party source |
335|---|---|
336| Programmatic API (`createEmulator`, `url`, `reset()`, `close()`), Vitest/Jest wiring, config auto-detection order, token fallback | `references/upstream.md` (synced from `vercel-labs/emulate`, `skills/emulate/SKILL.md`) |
337| GitHub endpoint recipes, GitHub App JWT seeding, Octokit and Auth.js base-URL wiring, GitHub OAuth flow | https://github.com/vercel-labs/emulate/blob/main/skills/github/SKILL.md |
338| Google OIDC discovery, JWKS, authorize/token/userinfo/revoke, PKCE, `google-auth-library`, Passport, `openid-client` | https://github.com/vercel-labs/emulate/blob/main/skills/google/SKILL.md |
339| Vercel endpoint recipes, cursor pagination, team scoping, integration OAuth flow | https://github.com/vercel-labs/emulate/blob/main/skills/vercel/SKILL.md |
340| Every other emulator (Slack, Apple, Entra, AWS, Okta, Resend, Stripe, MongoDB Atlas, Clerk, Linear, Twilio) | https://github.com/vercel-labs/emulate/tree/main/skills |
341
342**What stays ours:** `references/ork-delta.md` (the corrections and house conventions that
343are not in any vendor doc), `references/cli-reference.md`, `references/api-coverage.md`,
344`references/dep-to-emulator-map.json`, `scripts/auto-discover.sh`, and everything in `rules/`.
345
346Read `references/ork-delta.md` before copying any snippet out of a vendor doc. It records
347the two API facts vendor prose does not spell out (the exported factory is `createEmulator`,
348and `seed` in the programmatic options is an object rather than a path) plus the
349`*_API_BASE` env-var convention this repo uses instead of the vendor's `*_EMULATOR_URL`.
350
351## Related Skills
352
353- `testing-integration` — Integration test patterns (emulate as first choice for API tests)
354- `testing-e2e` — End-to-end test patterns with emulated backends
355- `testing-unit` — Unit test patterns (use emulate for API-dependent units)
356- `security-patterns` — Auth token patterns (emulate token seeding)
357
358## CLI Reference
359
360See `references/cli-reference.md` for all CLI flags and commands.