-
Notifications
You must be signed in to change notification settings - Fork 13
/
gulpfile.js
54 lines (47 loc) · 1.38 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var yargs = require('yargs');
var argv = yargs.argv;
var gulp = require('gulp');
var webdriver = require('gulp-webdriver');
var del = require('del');
var shell = require('gulp-shell');
var semistandard = require('gulp-semistandard');
var customWdioConfig = {};
if (argv.baseUrl) {
customWdioConfig.baseUrl = argv.baseUrl;
}
if (argv.spec) {
customWdioConfig.spec = argv.spec;
}
gulp.task('clean', function () {
return del([
'./allure-results',
'./allure-report'
]);
});
gulp.task('semistandard', function () {
return gulp.src('./test/**/*.js')
.pipe(semistandard())
.pipe(semistandard.reporter('default', {
breakOnError: true
}));
});
var testsFailed = false;
gulp.task('wdio', ['clean'], function() {
return gulp.src('wdio.conf.js').pipe(webdriver(customWdioConfig))
.on('error', function (err) {
// We still want the report to generate if a test fails, so surpress the error
testsFailed = true;
this.emit('end');
});
});
gulp.task('generate-report', ['clean', 'wdio'], shell.task([
'./node_modules/.bin/allure generate allure-results'
]));
gulp.task('test', ['generate-report'], function () {
// If tests failed earlier, we want to make sure that gulp exits with 1
if (testsFailed) {
console.log('Some tests failed. Check the report by running `npm run report`.');
process.exit(1);
}
});
gulp.task('default', ['semistandard', 'test']);