@mirrahq/vitest plugin wraps your Vitest config so every test runs against Mirra mirrors instead of the real vendors. You don’t change your tests. You change one line of config.
Install
Wire it up
Wrap your Vitest config inwithMirra():
What the plugin does
Before the test run
Calls
mirra up internally with the configured mirrors. Reuses a warm-start session if the mirror set + seeds haven’t changed since the last run (2-second warm start vs 1.8-second cold).Between each test (optional)
Calls
resetMirraMirrors() to wipe state back to the seed. Enabled by resetBetweenTests: true. Adds ~50-100ms per test; usually worth it.During each test
Your Vitest tests run normally. A TLS proxy routes
api.stripe.com, api.resend.com, and api.twilio.com to the session’s mirror URLs — no changes needed in your SDK client setup.Configuration
Using reset manually
If you want finer control thanresetBetweenTests, import the reset function and call it where you want:
resetMirraMirrors() returns a Promise that resolves when every mirror is back at its seed. See CLI reset reference for the underlying behavior.
Testing webhooks
The Mirra-backed mirrors fire real webhooks on real schedules. Your tests need to handle the async nature:waitForWebhook() is a helper that subscribes to the session’s event stream, filters, and resolves when a matching event arrives. See API reference for the raw event shape.
Parallel test runs
Vitest runs files in parallel by default. The Mirra plugin gives every file its own session whenresetBetweenFiles: true, so parallel files never contaminate each other:
resetBetweenFiles: false (the default), all files share one session and you must design tests not to step on each other — usually via resetBetweenTests: true.
CI
No code changes. Just addMIRRA_TOKEN to your CI secrets:
Where to go next
First scenario
Write a markdown scenario — complements Vitest for agent + integration tests.
CI integration
End-to-end CI wiring with Mirra gates.
mirra reset
The command resetMirraMirrors() wraps.