Quantcast
Viewing all articles
Browse latest Browse all 4829

How can I get moduleFor() to resolve a custom factory registered with the container in an initializer?

@skaterdav85 wrote:

How can I get moduleFor() to resolve a custom factory registered with the container in an initializer?

I'd like to create a custom class, app/validations/user that gets resolved out of the container. I've set up the initializer to register this class with the container.

import UserValidation from 'demo/validations/user';

export function initialize(application) {
  application.register('validations:user', UserValidation, { singleton: false });
  application.inject('route', 'userValidation', 'validations:user');
}

However, in test mode, moduleFor() doesn't run this initializer so I get "Attempting to register an unknown factory: 'validations:user'"

import { moduleFor, test } from 'ember-qunit';

moduleFor('validations:user', 'Unit | Validations | user', {
  needs: []
});

test('no options', function(assert) {
  assert.ok(true);
});

Anyone know what I am missing? Thank you!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4829

Trending Articles