Introducing ember-mirage-gen
Alwar G
Posted on November 18, 2020
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
- fixture
- factory
- 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 />
2.In config file
let ENV = {
'ember-mirage-gen': {
isEnabled: environment === 'development',
}
};
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.
Posted on November 18, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.