I have a custom ember test helper that I want to use in an integration test for my component. I created the helper with ember cli using the command ember g test-helper component-helper
, and double checked that everything follows the guide on the ember website. However, when I run ember test --server
I get an error in the integration test stating that the helper is undefined because of an Object.TestLoader.moduleLoadFailure
. Here is what I have:
helpers/component-helper.js
import Ember from 'ember';
import { test } from 'ember-qunit';
export default Ember.Test.registerHelper('componentHelper', function (app, name, opts) {
opts = opts || {};
test(name, function (assert) {
if (opts.setup) {
// we can use this to provide out component tests with stuff
opts.setup.call(this);
}
andThen(() => this.render(Ember.HTMLBars.compile(opts.template)));
andThen(() => opts.test.call(this, assert));
});
});
helpers/start-app.js
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
import './component-helper';
export default function startApp(attrs) {
var application;
var attributes = Ember.merge({}, config.APP);
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
Ember.run(function() {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
}
integration/pods/components/input-checkbox/component-test.js
import { moduleForComponent } from 'ember-qunit';
moduleForComponent('input-checkbox', 'Integration | Component | input checkbox', {
integration: true
});
componentHelper('regular checkbox', {
template: '{{input-checkbox}}',
test(assert) {
assert.equal(1, 1);
}
});
Aucun commentaire:
Enregistrer un commentaire