grunt-loop-mocha:警告:任务" loopmocha"未找到。使用--force继续

时间:2017-07-14 06:24:29

标签: javascript node.js gruntjs mocha node-modules

我正在使用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在不同的浏览器中执行测试。

1 个答案:

答案 0 :(得分:0)

我通过加载grunt-loop-mocha作为NPM任务来解决它。

grunt.loadNpmTasks('grunt-loop-mocha');

https://softwaretestingboard.com/qna/2253/grunt-loop-mocha-warning-task-loopmocha-found-force-continue

相关问题