0
[grunt-loop-mocha] Warning: Task "loopmocha" not found. Use --force to continue.

Open 1 Answers 17 Views

I am using grunt-loop-mocha. When I execute grunt test, I get below error:

Warning: Task "loopmocha" not found. Use --force to continue.

Aborted due to warnings.

Here is my code:

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');
	
};

 

1 Answer

0

I got it resolved by loading grunt-loop-mocha as an NPM task.

 

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

 

Your grunt file should look like below.

 

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"
                },
                iterations: [
                    {
                        "description": "first",
                        "env1": {
                            "someKey": "some value"
                        }
                    }
                ]
            }
        }
    });
    grunt.loadNpmTasks('grunt-loop-mocha');
	grunt.registerTask('test', 'loopmocha');
	
};

 

answered Jul 15 by stbadmin (4,970 points)
...