Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4826

Ember CLI Mirage - Create mock and use fixture data?

$
0
0

@corrspt wrote:

Hi all,

I’ve been trying to setup an acceptance test using ember-cli-mirage, but I’ve hit a roadblock. I’ve got a model, called pqr with a relation (one to one) to a model called pqr-standard.

I’ve defined a set of fixtures for pqr-standard as they are mostly fixed. I want to create an acceptance test that visits pqr/:id and comes with a pre-selected standard (as the presence of a given standard influences some parts of my form)

My thinking was something like:

server.loadFixtures();
server.create('pqr', { standard: ''} ) <---- Here lies the problem

I would like to load one of the fixture values in the standard property. I’ve tried making this work on the route handler side, but no luck

this.get('/pqrs/1', function({ db }, request) {
let pqr = db.pqrs.insert({
  standard: db.pqrStandards[0]
});
return pqr;
});

I’ve tried making on the acceptance-test file, by making a new server.create('pqr-standard') (and using it when creating the pqr) and the value is added to mirage’s database, but in my form I don’t see the value for the standard I’ve created.

So my questions are: How can I use, server.create(‘model’) and pass it an attribute which is a fixture? Or am I doing something wrong here?

Thanks!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles