How can I get my grunt mocha test result in a html file?

296 Views Asked by At

Using

mochaTest: {
   test: {
    options: {
      reporter: 'html-cov',
      captureFile: 'coverage.html' 
    },
    src: ['tests/*.js']
  }
}

in my gruntfile is gives me

"html-cov" reporter not found

warning. How can I get my test result in a html file and view it ?

Thx..

Also I'm using grunt.loadNpmTasks('grunt-selenium-standalone') task.

1

There are 1 best solutions below

1
On BEST ANSWER

Please check the following link:

https://github.com/pghalliday/grunt-mocha-test

Here you get the complete example, may it'll help you..

You can use Mochawesome. It is a custom reporter for use with the Javascript testing framework, mocha. It generates a nice HTML/CSS report that helps visualize your test suites.

First, you need to install the plugin:

npm install --save-dev mochawesome

Then you change your grunt-mocha-test reporter:

mochaTest: {
    test: {
        options: {
            reporter: 'mochawesome', //You need to change this !
            colors: true,
            summery: true,
            captureFile: 'results.html',
            quiet: false,
            clearRequireCache: true
        },
        src: ['test/*spec.js'],
        excludes: ['plugins']
    },
    'travis-cov': {
        options: {
            reporter: 'travis-cov'
        }
    }
},