I'm trying to use ember-qunit for testing. I have this pseudo-code here: (http://jsbin.com/zejacati/5/edit)
Ember.Foo = Ember.Namespace.create();
Ember.Foo.FooComponent = Ember.Component.extend({
template: Ember.Handlebars.compile('<h2>Hello!</h2>')
});
Ember.Handlebars.helper('foo-component', Ember.Foo.FooComponent);
window.App = Ember.Application.create();
window.App.setupForTesting();
emq.globalize();
setResolver(Ember.DefaultResolver.create({
namespace: window.App
}));
moduleForComponent('foo-component', 'Foo component testing');
test('First true test', function () {
var component = this.subject();
ok(true, true);
});
and ember sayed me:
Setup failed on First true test: Attempting to register an unknown factory:
component:foo-component
I think the problem in resolver, but I don't know how fix it.
Any ideas?
Thank you.
I think your problem might be because you put FooComponent
on the Ember
object instead of the App
object.
Instead of:
Ember.Foo.FooComponent = Ember.Component.extend({
template: Ember.Handlebars.compile('<h2>Hello!</h2>')
});
try this instead:
App.FooComponent = Ember.Component.extend({
template: Ember.Handlebars.compile('<h2>Hello!</h2>')
});
... because that is where Ember's default resolver would look for component:foo-component
.
I am not familiar with Ember.Namespace
(have not used it before), and thus also how it would impact this test - so try this version first, without any namespace, and then try to work the namespace back in.