3 What is Karma?

First, what is Karma? 
1, Karma is a set of front-end test run framework developed by Google team,
2, the core of the framework is the Karma Jasmine, Jasmine is responsible for complete automated testing Javascript to generate coverage reports.
3, Karma framework is primarily to do the following:
(1) Start a web server, generates a page js source and js test script;
(2) running the browser loads the page, and displays the results of the test;
(3) if on detection , when the file was modified, continue to perform the above process.
4, the installation environment Karma: -g karma I NPM-CLI
. 5, the installation package karma: NPM-I --save karma dev
. 6, the test environment initialization: the init karma
. 7, run karma: karma start
the actual project, may require something Webpack and used for ES6
. 8, the installation-WebPACK Karma: I --save NPM-dev-WebPACK Karma
. 9, mounted babel: npm i --save-dev babel -loader babel-core babel-preset-es2015
case, karma start , not one hundred percent of Coverages
10, mounted Istanbul (detection Coverages): I --save NPM-dev-plugin-Istanbul Babel
. 11, item address: https: //github.com/xiaojimao18/karma-example
12. Source: https: //segmentfault.com/a/1190000006895064

Second, the type of test
1, end to end testing - Integration testing - unit testing
2, Test Driven Development - Behavior Driven Development

Third, under gulp, the establishment of karma task
var karma = require('karma').server;
gulp.task('test', function(done) {
    karma.start({
        configFile: __dirname + '/tests/my.conf.js',
        singleRun: true
    }, function() {
        done();
    });
});
Fourth, before each gulp execution, first test

 

gulp.task('default',['test'],function(){

})

  

Guess you like

Origin www.cnblogs.com/gushixianqiancheng/p/10963912.html