Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
267 views
by The go-to Tester (181 points)
edited by

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 like 0 dislike
by The go-to Tester (181 points)

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

 


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...