Injecting helper classes



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 :frowning:

Thanks Rob


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;


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();


You should have access to stub any function/service/etc using the registry

Here is how I would stub a helper func to do nothing (from inside an integration test/maybe a unit test)

this.registry.register('helper:foobar', function() {});