Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to place fixtures?

Where should I define fixtures in an Ember JS app generated with ember-cli? I've tried numerous places, such as app.js and within a folder called "fixtures".

like image 725
YWCA Hello Avatar asked Mar 31 '14 22:03

YWCA Hello


People also ask

Where do I put pytest fixtures?

Fixtures and their visibility are a bit odd in pytest. They don't require importing, but if you defined them in a test_*. py file, they'll only be available in that file. You can however put them in a (project- or subfolder-wide) conftest.py to use them in multiple files.

Where should Conftest py be located?

You can put fixtures into individual test files, but to share fixtures among multiple test files, you need to use a conftest.py file somewhere centrally located for all of the tests. For the Tasks project, all of the fixtures will be in tasks_proj/tests/conftest.py.

Which fixture is instantiated first?

Higher-scoped fixtures are instantiated first¶ Within a function request for features, fixture of higher-scopes (such as session ) are instantiated first than lower-scoped fixtures (such as function or class ).

How do you use fixtures?

To access the fixture function, the tests have to mention the fixture name as input parameter. Pytest while the test is getting executed, will see the fixture name as input parameter. It then executes the fixture function and the returned value is stored to the input parameter, which can be used by the test.


1 Answers

After digging around I discovered that changing Ember.MODEL_FACTORY_INJECTIONS = true; in the file app.js to Ember.MODEL_FACTORY_INJECTIONS = false; is solving the problem.

Through this question I also found another solution where you don't have to change the configuration:

Instead of defining the fixtures as described you have to use reopenClass:

//models/item.js
var Item = DS.Model.extend({...});

Item.reopenClass({
  FIXTURES: [
    { id: 1, ... },
    { id: 2, ... }
  ]
});

export default Item

Happy developing with Ember and ember-cli :-)

like image 174
stravid Avatar answered Sep 22 '22 00:09

stravid