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.
mirage-gen-common
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
mirage-gen-api
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: https://www.npmjs.com/package/ember-mirage-gen
Github link: https://github.com/AlwarG/ember-mirage-gen

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

Oldest comments (0)