这是我的gulpfile:
var gulp = require('gulp');
var cucumber = require('gulp-cucumber')
var browserStack = require('gulp-browserstack');
gulp.task('cucumber', function() {
return gulp.src('features/my_feature.feature')
.pipe(browserStack.startTunnel({
key: '<itsasecret>'
}))
.pipe(cucumber({}))
.pipe(browserStack.stopTunnel());
});
当所有场景通过时,gulp挂起,永不退出。 任何帮助将不胜感激。
答案 0 :(得分:0)
这是我最终使用的解决方案
const gulp = require('gulp');
const cucumber = require('gulp-cucumber')
const BrowserStackTunnel = require('browserstacktunnel-wrapper');
var tunnel;
function startTunnel(options) {
return new Promise((resolve, reject) => {
tunnel = new BrowserStackTunnel(options);
tunnel.start(function(error) {
error ? reject(error) : resolve();
});
});
}
function stopTunnel(error) {
return new Promise((resolve, reject) => {
function resolveOrReject() {
error ? reject(error) : resolve();
}
tunnel ? tunnel.stop(resolveOrReject) : resolveOrReject();
});
};
function createCucumberPromise(src, options) {
return function() {
return new Promise((resolve, reject) => {
gulp.src(src)
.pipe(cucumber(options))
.on('end', resolve)
.on('error', reject);
});
}
};
gulp.task('cucumber', () => {
return startTunnel({
key: '<stillasecret>'
})
.then(createCucumberPromise('features/my_feature.feature', {
// format: 'json:output.json'
// tags: '@wip'
}))
.then(stopTunnel, stopTunnel);
});