我正在使用grunt-loop-mocha节点模块。当我执行 grunt test 时,我得到以下错误:
Warning: Task "loopmocha" not found. Use --force to continue.
Aborted due to warnings.
这是我的代码:
module.exports = function(grunt) {
require("grunt-loop-mocha")
// Project configuration.
grunt.initConfig({
loopmocha: {
src: ["./tests/***-specs.js"],
options: {
mocha: {
parallel: true,
globals: ['should'],
timeout: 3000,
ui: 'bdd',
reporter: "xunit-file"
},
loop: {
reportLocation: "test/report"
},
env1: {
stringVal: "fromfile"
},
env2: {
jsonVal: {
foo: {
bar: {
stringVal: "baz"
}
}
}
},
iterations: [
{
"description": "first",
"env1": {
"someKey": "some value"
}
},
{
"description": "second",
"env2": {
"someOtherKey": "some other value"
}
},
{
"description": "third",
"mocha": {
"timeout": 4000
}
},
{
"description": "fifth",
"env1": {
"anotherKey": "BLERG"
},
"env2": {
"yetAnotherKey": 123
}
}
]
}
}
});
grunt.registerTask('test', 'loopmocha');
};
我甚至安装了 npm i grunt-loop-mocha 。
不确定缺少什么。基本上,我试图使用grunt-loop-mocha在不同的浏览器中执行测试。
答案 0 :(得分:0)
我通过加载grunt-loop-mocha作为NPM任务来解决它。
grunt.loadNpmTasks('grunt-loop-mocha');