1.3 gulp-mocha和mochawesome
作者:互联网
一、gulp官方文档
https://v3.gulpjs.com.cn/docs/recipes/mocha-test-runner-with-gulp/
var gulp = require('gulp');
var mocha = require('gulp-mocha');
gulp.task('default', function() {
return gulp.src(['test/test-*.js'], { read: false })
.pipe(mocha({
reporter: 'spec',
globals: {
should: require('should')
}
}));
});
二、执行gulp default命令,便可执行mocha测试
三、gulp-mocha
gulp-mocha提供了mocha(options?)方法,options是一个对象
如下摘抄部分参数,详细参考https://www.npmjs.com/package/gulp-mocha/v/8.0.0
其中reporter参数可以配置mochawesome
ui
Type:
string
Default:bdd
Values:bdd
tdd
qunit
exports
Interface to use.
reporter
Type:
string
Default:spec
Values: ReportersReporter that will be used.
This option can also be used to utilize third-party reporters. For example, if you
npm install mocha-lcov-reporter
you can then do usemocha-lcov-reporter
as value.reporterOptions
Type:
object
Example:{reportFilename: 'index.html'}
Reporter specific options.
四、mochawesome
文档地址:https://www.npmjs.com/package/mochawesome
var mocha = new Mocha({
reporter: 'mochawesome',
reporterOptions: {
reportFilename: 'customReportFilename',
quiet: true,
},
});
mochawesome的主要参数
Option Name | Type | Default | Description |
---|---|---|---|
quiet | boolean | false | Silence console messages |
reportFilename | string | mochawesome | Filename of saved report Applies to the generated html and json files. |
html | boolean | true | Save the HTML output for the test run |
json | boolean | true | Save the JSON output for the test run |
consoleReporter | string | spec | Name of mocha reporter to use for console output, or none to disable console report output entirely |
配置mochawesome后,执行gulp default,将会生成测试报告,在服务器的持续集成中,可以将测试报告部署到tomcat服务器下,实现在线查看
标签:reporter,mocha,gulp,test,output,mochawesome 来源: https://blog.csdn.net/LetsStudy/article/details/115407655