Javascript ember cli应用程序的应用程序/UTIL中的单元测试模块
在Javascript ember cli应用程序的应用程序/UTIL中的单元测试模块,javascript,ember.js,qunit,ecmascript-6,ember-cli,Javascript,Ember.js,Qunit,Ecmascript 6,Ember Cli,在“util:transforms”上调用模块, 但是.subject是未定义的 到目前为止,我得到的测试文件是: import { test, moduleFor } from 'ember-qunit'; import TransformUtil from 'myapp/utils/transforms'; moduleFor('util:transforms', "Unit - TransformUtil"); test("Exists", function(){ expect(1
“util:transforms”
上调用模块,
但是.subject
是未定义的
到目前为止,我得到的测试文件是:
import { test, moduleFor } from 'ember-qunit';
import TransformUtil from 'myapp/utils/transforms';
moduleFor('util:transforms', "Unit - TransformUtil");
test("Exists", function(){
expect(1);
ok(this.subject() instanceof TransformUtil);
});
对其他类型的模块执行相同的操作,
e、 g.“路由:索引”
,似乎可以正常工作;
app/utils
文件夹的处理方式似乎有所不同。解析程序无法识别实用程序(app/utils
),因此您需要手动导入。正如Ember CLI文档所述:
解析程序可以加载app目录中的所有模块,但通常应使用import语句手动加载mixin和utils等类
因此,您应该删除模块的第一个参数,然后在测试中使用导入的TransformUtil
对象