Mirage JS is an API mocking library that lets you build, test and share a complete working JavaScript application without having to rely on any backend services. Unlike other mocking libraries, Mirage JS makes it easy to recreate dynamic scenarios, the kind that are typically only possible when using a real production server.
Mirage runs alongside the rest of your frontend JavaScript code — no new server processes or terminal windows needed. Use the devtools you know and love to write UI code that’s ready for the network.
Mirage JS runs in the browser. It intercepts any XMLHttpRequest
or fetch
requests your JavaScript app makes and lets you mock the response. That means you can develop and test your app just as if it were talking to a real server.
The best DX for frontend development
Say goodbye to configuring painful backend environments just to hack on your UI. Mirage runs alongside the rest of your frontend code, so there’s no new infrastructure for you to learn.
New collaborators can clone your frontend codebase, run npm install, and have a complete local offline dev environment up and running in seconds – no environment variables or auth tokens needed.
Write high-level UI tests that stress your networking code
With Mirage, you can write automated tests against your API no matter what state it’s in. Test how your app handles 0 blog posts, 10, or 1000 – or even how it behaves when your server is slow or responds with an error.
No messy mocking code or handcrafted API responses in your tests. Just real-world scenarios validating the entire functionality of your full application.
Share a fully-working UI without running a backend
Because Mirage realistically mocks out your entire API server, you can share a clickable, working prototype of your JavaScript application without needing to run any backend services.
Get high-quality feedback from your users and iterate faster than ever, before you start investing in expensive server-side infrastructure.
You can get started with Mirage JS from here.