DEV Community

Alwar G
Alwar G

Posted on


Introducing ember-mirage-gen

As an ember developer, I always frustrated while writing the test cases. Because we should copy the sample response as well as a sample request. Particularly in factories, it will make the frustration because of faker data. So what should we do? 🤔
I have created the ember addon of ember-mirage-gen to solve this requirement.
It will list the requests as shown in the below image.
After clicking the specific request, we can have the three sections
1. config file - response of the initiated request
2. DB section - factories and fixtures
3. Test file - factory and fixture creation
The above three sections are editable. So you can change data as you want.

Here we can choose the type of database for the particular node from the object tree as shown in the above image. The database options are

  1. fixture
  2. factory
  3. Normal(Added to the config file response)

Now you can click the Generate DB button to get the mocked data.

How to use it?

The answer is simple. You should do the following two things.

1. In template file

  <MirageGen />
Enter fullscreen mode Exit fullscreen mode

2.In config file

let ENV = {
  'ember-mirage-gen': {
    isEnabled: environment === 'development',

Enter fullscreen mode Exit fullscreen mode

NPM link:
Github link:

Thank you for reading this post 🙏. I hope you learned something. Feel free to post your comments if you want to share something.

Top comments (0)

Visualizing Promises and Async/Await 🤯

async await

☝️ Check out this all-time classic DEV post