MirageJS: An API mocking library for frontend development
1–10 of 52 posts
Re: MirageJS: An API mocking library for frontend development
#2I don't know how many times mocking up a UI I start to throw some random JS objects in a file and then inevitably after a few hours, those random JS objects are unmanageable and contain very small differences between what my API will deliver.
Using Mirage from the start of projects has made my life a lot easier, it also provides a nice sanity check between what the backend delivers and what the frontend actually expects.
Re: MirageJS: An API mocking library for frontend development
#3Re: MirageJS: An API mocking library for frontend development
#4Mirage is extracted it from an addon that's been widely used in the Ember ecosystem for the past 4 years, at companies like Apple, Heroku, Square and Footlocker.
Nearly all frontends need to talk to an API, no matter what framework they're built with! So over the past year I've made Mirage work with any tool or test runner.
I really believe deeply in the frontend-first workflow, and Mirage makes that easier than ever. If it sounds interesting to you, check out the lib + let me know what you think!
Re: MirageJS: An API mocking library for frontend development
#5Re: MirageJS: An API mocking library for frontend development
#6Re: MirageJS: An API mocking library for frontend development
#7Re: MirageJS: An API mocking library for frontend development
#8Just my two cents: Mirage is freaking great because it makes mocking shit out pretty much as easy as possible and pretty damn correct. I don't know how many times mocking up a UI I start to throw some random JS objects in a file and then inevitably after a few hours, those random JS objects are unmanageable and contain very small differences between what my API will deliver. Using Mirage from the start of projects ha…
I have another question. Mirage is installed as a dev dependency. But all the examples show it being used in the application code. Do you maintain a separate branch without the import of Server, etc? Or is webpack smart enough to remove all imports/usage of dev dependencies in the prod build? I don't think I've ever imported dev dependencies into app code before.
For that matter, how does it provide a sanity check between what the back end delivers and the front end expects? Do you mean compared to coding to a spec with no mocking? Like when the back end doesn't exist yet?
Clearly I'm missing something. Could be the sleep deprivation.
Re: MirageJS: An API mocking library for frontend development
#9So you install it as a dev dependency via npm.
So is it running ... with the client app as a proxy between the client application and just waiting for the API requests and taking those responding?
Is it possible to configure some delay in responses?
Re: MirageJS: An API mocking library for frontend development
#10Now make a component on top that runs a network request and injects the network response into it.
Now you have a reusable component independent of the api. Your network function can be tested individually. Your top level component doesn’t need testing as that is the part that would be mocked.
You can now test your actual component without any mocking.
If you need some dummy data to show before the backend team is ready, this is trivial. Guess I’m just not a Big enough mocking fan to ever need a library for what is such a small thing in my experience