emulate
repository·main·Indexed 23 days ago
https://github.com/vercel-labs/emulateemulate provides local, stateful, production-fidelity API emulation for services such as Vercel, GitHub, AWS, Stripe, and Resend. Designed for CI environments and no-network sandboxes, it acts as a drop-in replacement for real APIs rather than simple mocks. It supports standalone processes via npx emulate or embedded integration within Next.js and Nuxt applications using @emulators/adapter-next and @emulators/adapter-nuxt.
What's inside emulate
- The Stripe emulator provides a local emulation of the Stripe API, allowing you to test workflows involving customers, payment methods, sessions, intents, charges, products, prices, and checkout sessions. It includes a hosted checkout page and supports webhook delivery for specific events.
Microsoft Entra ID (Azure AD) Emulation Overview
mainThe Microsoft Entra ID emulator provides v2.0 OAuth 2.0 and OpenID Connect (OIDC) emulation. It supports authorization code flow with PKCE, client credentials grant, RS256 ID tokens, OIDC discovery, and a Microsoft Graph/v1.0/meendpoint.GitHub API Emulator Capabilities
mainThe GitHub API emulator provides a fully stateful environment. All operations (Create, Update, Delete) persist in memory and affect related entities, allowing for realistic testing of complex workflows. The emulator supports a wide range of endpoints including Users, Repositories, Issues, Pull Requests, Webhooks, Actions, and Search.Emulate MongoDB Atlas
mainMongoDB Atlas emulation provides an in-memory document storage system that supports CRUD, filtering, and aggregation. It implements both the Atlas Admin API v2 and the Atlas Data API v1.Resend API Emulation Overview
mainThe Resend emulator provides a local environment for testing email-related workflows. It supports emulating email sending, domain management, API key lifecycle, audience and contact management, and provides a local inbox to view captured messages.Use the Linear GraphQL API emulator
mainThe
@emulators/linearpackage provides a stateful GraphQL API emulator for local development and CI. It targets a focused subset of the Linear GraphQL API.API Surface
- Endpoint:
POST /graphql - Supported Queries:
viewer,organization,users,teams,workflow states,issues,comments,labels,projects,cycles,webhooks, andagent sessions. - Supported Mutations:
issues,comments,labels,webhooks, and basicagent sessionsandactivities.
Authentication
- Supports Personal API keys and OAuth bearer tokens.
- Supports OAuth flows:
authorize,token,refresh,revoke,PKCE,client credentials, andapp actor tokens.
Webhooks
- Delivers Linear-shaped webhooks including the following headers:
Linear-DeliveryLinear-EventLinear-Signature
Inspector
- A local inspector is available at the root path (
/).
OAuth Actor Configuration
The
actorconfiguration determines the authorization flow:actor: user: Uses authorization code flows.actor: app: Uses the app install flow and can request client credentials tokens.
Note: This is not a complete Linear clone. Any unsupported GraphQL fields will return GraphQL errors.
- Endpoint:
How Slack event dispatching works
mainWhen the Slack emulator performs state-mutating writes, it dispatches
event_callbackpayloads to configured webhook URLs. These payloads follow Slack's standard Events API format. Supported event types include:- Messages:
messageevents forchat.postMessage,chat.update(subtypemessage_changed),chat.delete(subtypemessage_deleted), and incoming webhooks (subtypebot_message). - Reactions & Pins:
reaction_added/reaction_removedforreactions.add/reactions.remove, andpin_added/pin_removedforpins.add/pins.remove. - Lifecycle:
channel_archive/channel_unarchive(public),group_archive/group_unarchive(private), andchannel_rename/group_rename. - Channel Metadata:
messagewithchannel_topic/channel_purpose(public) orgroup_topic/group_purpose(private) subtypes. - Membership:
member_joined_channelandmember_left_channelfor invite, join, leave, and kick actions. - Direct Messages/MPIM:
im_created,im_open,im_close,im_marked, and group open/close/marked events. - User & Presence:
user_changefor profile writes andpresence_changefor presence writes. - Files:
file_created,file_shared,file_deleted, andmessagewith subtypefile_sharefor shared file uploads.
- Messages:
Handle Linear Webhooks
mainWebhook subscriptions can be created via the
webhookCreatemutation or through the seed configuration. When a write occurs, the emulator dispatches Linear-shaped payloads with the following headers:Linear-DeliveryLinear-EventLinear-Signature
Authenticate with the AWS Emulator
mainThe emulator uses Bearer token authentication. Pass tokens via the
Authorization: Bearer <token>header. Permissions are scoped using patterns likes3:*,sqs:*,iam:*, andsts:*.Example Request
curl http://localhost:4006/ \ -H "Authorization: Bearer test_token_admin"Configure Stripe Webhooks
mainThe Stripe emulator delivers webhook events to your configured webhook URLs. Supported events include:
checkout.session.completed: Triggered when a checkout session is completed.checkout.session.expired: Triggered when a checkout session expires.
How OAuth emulation works
mainThe OAuth emulation flow follows these steps:
- Authorization Request: Clicking a provider button redirects the user to
/api/auth/[provider]. This route constructs the OAuth authorize URL and redirects the browser to the local emulator. - User Selection: The emulator presents a user-picker page. You select a seeded user from the list.
- Callback with Code: The emulator redirects the browser back to the application's callback route (
/api/auth/callback/[provider]) including an authorization code. - Token Exchange: The application's callback route exchanges the authorization code for an access token, retrieves user information, and establishes a session via an HTTP-only cookie.
- Authentication: The application dashboard displays the authenticated user's profile and the retrieved access token.
- Authorization Request: Clicking a provider button redirects the user to
How persistence works in Nuxt emulators
mainThe persistence lifecycle follows these rules:
- Cold start: The adapter attempts to
load()state from the persistence adapter. If found, it restores the Store and token map. If not found, it seeds from the provided config and saves the initial state. - Mutating requests: After
POST,PUT,PATCH, orDELETErequests, the state is saved via the adapter. Saves are serialized through an internal queue to prevent race conditions. - No configuration: If no
persistenceadapter is provided, the system falls back to pure in-memory storage, meaning seed data re-initializes on every cold start.
- Cold start: The adapter attempts to