Hello! I'm Sam and I built Mirage JS to be a framework-agnostic API mocking library. Mirage 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…
MirageJS: An API mocking library for frontend development
31–40 of 52 posts
Re: MirageJS: An API mocking library for frontend development
#32Hello! I'm Sam and I built Mirage JS to be a framework-agnostic API mocking library. Mirage 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…
Re: MirageJS: An API mocking library for frontend development
#33Does anyone have any suggestions on a way to start with an OpenAPI spec and end up with a mock data set? With Mirage it seems easy enough to mock our API directly from scratch, but if we could save a few steps and go from OpenAPI spec to mocked front end that would be bliss.
Re: MirageJS: An API mocking library for frontend development
#34Re: MirageJS: An API mocking library for frontend development
#35What is the benefit of a request mocking framework versus hiding all api requests behind a module? Instead of // MyComponent.js const users = await fetch(... Use this // MyComponent.js const users = await api.getUsers() // api.js export default { getUsers() { return fetch(... } } To mock, you replace the entire api module (or individual functions).
Re: MirageJS: An API mocking library for frontend development
#36What is the benefit of a request mocking framework versus hiding all api requests behind a module? Instead of // MyComponent.js const users = await fetch(... Use this // MyComponent.js const users = await api.getUsers() // api.js export default { getUsers() { return fetch(... } } To mock, you replace the entire api module (or individual functions).
The first page of the docs list a few reasons. https://miragejs.com/docs/getting-started/introduction "Use a client-side interceptor to handle your app's network requests. ... This is the most flexible approach, but it requires you to start from scratch in each project, and leaves it up to you to enforce conventions across your apps." "Importantly, because Mirage mocks the HTTP boundary instead of the JavaScript code…
Re: MirageJS: An API mocking library for frontend development
#37This looks really cool. Is there a difference between this and json-server [0]? 0: https://github.com/typicode/json-server
Re: MirageJS: An API mocking library for frontend development
#38Re: MirageJS: An API mocking library for frontend development
#39Earlier quoted context omitted.
The first page of the docs list a few reasons. https://miragejs.com/docs/getting-started/introduction "Use a client-side interceptor to handle your app's network requests. ... This is the most flexible approach, but it requires you to start from scratch in each project, and leaves it up to you to enforce conventions across your apps." "Importantly, because Mirage mocks the HTTP boundary instead of the JavaScript code…
How is this the best/most flexible approach? What if you decide to move from REST to GQL? GQL to websockets? By mocking the HTTP endpoint you’re too low in the stack. At that point, I feel like you might have better success with using the actual backend and swap out the DB with mock data.