I have a fixture create which looks somewhat like this.
// mirage/fixtures/people.js
export default {
'people': [
{
'id': 1,
'name': 'Ram',
},
{
'id': 2,
'name': 'Raja',
}
]
}
Inside my acceptance test I'm using this array. But within my test, I want to modify this people array and add, suppose another object
{
'id': 3,
'name': 'John',
}
Note: I dont want to use factories as I dont want all datas to be dynamically generated, so I want to take this array from fixtures, push my new object into this array and then return it. What is the correct way to do it?
Note2: Don't suggest adding this object in fixtures itself, because I want to dynamically add items to the fixture based on conditions in my test.
This was pretty straight forward. In the mirage config, we shouldn't be doing this
instead read data from factories and populate original fixture values with
server.loadFixtures('people')
.So config.js will look like =>
Set your factory like this =>
Inside your test case, populate original and new values like this =>