grunt-mocha-chai-sinon

2019-07-12 admin

grunt-mocha-chai-sinon是什么

什么是grunt-mocha-chai-sinon,MochaJS + ChaiJS + SinonJS Test Runner

grunt-mocha-chai-sinon使用教程帮助文档

grunt-mocha-chai-sinon

Simple test runner for GruntJS using MochaJS as test framework, ChaiJS as assertion library for BDD and TDD and SinonJS as spyes/stubs/mocks utility library.

Gruntfile Example

// Gruntfile.js
module.exports = function(grunt) {

    // configure tasks
    grunt.initConfig({
        'mocha-chai-sinon': {
            build: {
                src: ['./specs/**/*.spec.js'],
	    	    options: {
        		    ui: 'bdd',
        			reporter: 'spec'
	        	}
        	}
        }
    });

    // load required tasks
    grunt.loadNpmTasks("grunt-mocha-chai-sinon");

    // register tasks for execution chain
    grunt.registerTask('test', [
		'mocha-chai-sinon'
	]);
};	

Test Coverage

Test coverage support is provided by node-jscoverage while source code is coverage enabled with BlancketJS.

In order to activate test coverage you need to create a new configuration for the mocha-chai-sinon task and name it coverage. The name matter!

'mocha-chai-sinon': {
    build: {
        src: ['./specs/**/*.spec.js'],
        options: {
            ui: 'bdd',
            reporter: 'spec'
        }
    },
    coverage: {
        src: ['./specs/**/*.spec.js'],
        options: {
            ui: 'bdd',
            reporter: 'html-cov',
            quiet: true,
            filter: '/foo/foo1/',
            captureFile: './coverage.html'
        }
    }
}

By default mocha-chai-sinon add test coverage support to all loaded files who match the /project-folder/src/ path but you can configure it with the coverage.options.filter option.

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-69551.html

文章标题:grunt-mocha-chai-sinon

回到顶部