@robwatkin wrote:
Hi,
I have an existing EmberJS code base onto which I want to introduce some unit tests but I need to mock out some included files. In the example below, how can I inject the HelperClass into the unit tests subject. At the moment the subject can't instantiate because the actual HelperClass pulls in a ton of stuff.
I am thinking that I can inject the class in with the "needs" property but I can't figure out how
![]()
Thanks Rob
app/models/my-model.js
import DS from 'ember-data'; import HelperClass from '../../utils/helper-class'; let model = DS.Model.extend({ Title: DS.attr('string'), }); HelperClass.something({ model: model }); export default model;
tests/unit/models/my-model-test.js
import { moduleForModel, test } from 'ember-qunit'; moduleForModel('my-model', 'Unit | Model | my model', { // Specify the other units that are required for this test. needs: [], }); test('it exists', function(assert) { // This throws an error !!!! var model = this.subject(); assert.ok(!!model); });
Posts: 1
Participants: 1