我用:
生成了一个自定义测试助手ember generate test-helper integration-for
这里删除了代码:
// tests/helpers/integration-for.js
import Ember from 'ember';
export default Ember.Test.registerHelper('integrationFor', function(app, key) {
return key;
});
我无法让它真正在组件测试中工作。我试过直接使用它:
// tests/integration/pods/components/itegration-item/component-test.js
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('integration-item', 'Integration | Component | integration item', {
integration: true
});
test('it renders the google analytics integration', function(assert) {
this.set('integration', integrationFor('key_here'));
});
会引发ReferenceError: integrationFor is not defined
错误。
我也试过导入它:
import integrationFor from '../../../helpers/integration-for';
根据documentation似乎不正确。
文档在最新版本(&gt; 2.4.x)中没有相应的部分,所以我不确定这是否是处理注册测试助手的正确方法,或者我是否正确地执行此操作。< / p>
答案 0 :(得分:0)
您需要执行以下操作,为tests / .jshintc添加帮助程序。 这样的事情。
{
"predef": [
"document",
"window",
"location",
...
"shouldHaveElementWithCount",
"dblclick",
"addContact",
"integrationFor"
],
...
}
您需要在tests / helpers / start-app.js
中导入帮助文件import integrationFor from "./integration-for";