Карма закрывающая браузеры после теста gulp
Я провожу базовые тесты с жасмином, используя пусковые установки Chrome и Firefox в карме из gulp. Но мои браузеры всегда закрываются после этого. Независимо от успеха или неудачи в тестах, даже после указания одного запуска как ложного в задаче и конфигурации.
Задание глотка:
karma = require('gulp-karma');
gulp.task('test', ['testsSetup'], function() {
// Be sure to return the stream
// NOTE: Using the fake './foobar' so as to run the files
// listed in karma.conf.js INSTEAD of what was passed to
// gulp.src !
return gulp.src('./foobar')
.pipe(karma({
configFile: 'karma.conf.js',
singleRun: false
}))
.on('error', function(err) {
// Make sure failed tests cause gulp to exit non-zero
console.log(err);
//this.emit('end'); //instead of erroring the stream, end it
});
});
karma.conf.js:
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome','Firefox'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
Последняя часть глотка выводится из успешных тестов:
Chrome 43.0.2357 (Windows 7 0.0.0): выполнено 3 из 3 УСПЕХ (0,041 с / 0,036 с)
Firefox 38.0.0 (Windows 7 0.0.0): Выполнено 3 из 3 УСПЕХ (0,001 с / 0,013 с)
ИТОГО: 6 УСПЕХОВ
Chrome 43.0.2357 (Windows 7 0.0.0): выполнено 3 из 3 УСПЕХ (0,041 с / 0,036 с)
Firefox 38.0.0 (Windows 7 0.0.0): Выполнено 3 из 3 УСПЕХ (0,001 с / 0,013 с)
ИТОГО: 6 УСПЕХОВ
[11:09:27] Закончено "испытание" через 4,52 с
Процесс завершен с кодом 0.
1 ответ
Когда вы используете gulp-karma, аргументы, которые вы передаете, отличаются от аргументов, которые вы передаете прямо карме. Вышеуказанный параметр singleRun игнорируется. Я изменил свою задачу на следующую (указав вместо этого действие), и она работает так, как вы ожидаете:
gulp.task('test', ['testsSetup'], function() {
// Be sure to return the stream
// NOTE: Using the fake './foobar' so as to run the files
// listed in karma.conf.js INSTEAD of what was passed to
// gulp.src !
return gulp.src('./foobar')
.pipe(karma({
configFile: 'karma.conf.js',
action: 'watch',
showStack: true
}))
.on('error', function(err) {
// Make sure failed tests cause gulp to exit non-zero
console.log(err);
this.emit('end'); //instead of erroring the stream, end it
});
});