Emulators
Stand-ins for sign-in, email, payments, Jira, Slack, GitHub, AWS and object storage that run inside every sandbox.
Each sandbox (a live copy of your app, also called a test environment) runs its own stand-ins for the outside services your app uses. Your app keeps its normal SDKs and URLs. Nothing real gets sent, and a test can check what your app sent.
These services have emulators.
| Area | Emulated |
|---|---|
| Sign-in | Google, any OpenID Connect provider (Auth0, Okta, Keycloak, Clerk), Amazon Cognito |
| Amazon SES, SendGrid, Resend, Postmark, Mailgun, Mailosaur | |
| Payments | Stripe billing (customers, Checkout, subscriptions, billing portal) |
| Work tools | Jira, Slack, GitHub |
| AWS | Secrets Manager, KMS, Parameter Store |
| Files | S3 and Google Cloud Storage |
| Anything else | A small script in your repo |
Add an emulator
-
List what your app calls.
cofactor sandbox guide feasibilitygives each dependency one verdict: built in, emulated, installable as a service, real, or unsupported. -
Declare the emulator under
emulation:incofactor.sandbox.yaml. For AWS, give each service its own section, such asemulation.aws.cognito. The emulator answers only the services you declare, and it doesn't intercept calls to the others.yamlemulation: email: {} jira: { tenant: acme }The plugin ids are
email,google-oauth,oidc,aws,stripe,github,jira,slackandscripted. Files useobject_storageinstead. -
Set
reload_on_prepare: trueon every service that calls an emulated provider. Without it, the service's calls fail TLS. -
Add personas if you emulate sign-in. Each persona becomes an account at the provider, so sign-in emulators need at least one. See Seed data and logins.
-
Claim a sandbox and trigger a send in your app. Then read what the emulator captured.
bashcofactor sandbox claim --application "Acme App" --wait cofactor sandbox run <sandbox id> email.sent-emails
The captured emails list after an invitation, with subject and recipient
Check it worked
cofactor sandbox envs --application "Acme App"
envs lists each declared plugin's operations. A test send shows up in email.sent-emails. The aws operations (aws.secrets, aws.cognito-pools and aws.parameters) show seeded state and read counts, not captured calls. A signed-out test completes your real sign-in button and callback as a persona. On an emulated domain, a call the emulator doesn't implement returns 501 and never reaches the real provider. A scripted emulator answers every call to its domains itself.
Go deeper
cofactor sandbox emulators <emulator id>prints one emulator's domains, config keys and operations.cofactor sandbox guide emulationcovers every option.- Object storage
- Receiving email covers test inboxes and reading the sign-in codes and links your app emails to a test user.
Provider details, scripted emulators and common errors.
Google. Declare google-oauth: {}, set your client id, secret and redirect URI through env:, and add personas. Cofactor's browser shows an account chooser listing each persona. It covers server-started redirect flows. One Tap, FedCM and popup sign-ins are unsupported.
OpenID Connect. Declare oidc: {} and point your app's issuer setting at the sandbox's public emulation address, with issuer_url: { port: emulation }.
Cognito. Declare emulation.aws.cognito with your real pool id and client id. Personas become the pool's users, and the hosted UI works.
Email. Mail through SES in an unlisted region, an unlisted provider host or SMTP leaves the sandbox. Leave SMTP unconfigured, or run Mailpit as a service.
Stripe and object storage. Run cofactor sandbox emulators stripe, and see object storage.
Your own emulator. Add emulation.scripted.<name> with run, domains, port and env. Every field is required, so use env: {} if you have none. The script serves plain HTTP on 127.0.0.1 at that port and answers GET / with a status below 400.
Errors. TLS errors mean the service lacks reload_on_prepare: true. An emulator that never becomes healthy in a pushed image needs openssl. No captured mail means it left through SMTP or an unintercepted host.