是否可以将gulp手表与jasmine-spec-reporter结合使用

时间:2016-09-26 09:20:43

标签: javascript gulp jasmine

我正在尝试将手表与jasmine-spec-reporter结合起来,这是我的gulpfile:

import Jasmine from 'jasmine';
import SpecReporter from 'jasmine-spec-reporter';

gulp.task('watch', () => {
  gulp.watch('./spec/**/*[sS]pec.js', ['jasmine']);
});

gulp.task('jasmine', () => {
  let jasmine = new Jasmine();
  jasmine.env.clearReporters();
  jasmine.addReporter(new SpecReporter());
  jasmine.loadConfigFile();
  jasmine.execute();
});

问题

如果我运行gulp jasmine它运行正常,但如果我运行监视任务它只执行一次:

$ gulp watch
> Starting 'watch'...
> Finished 'watch' after 8.82 ms
> Starting 'jasmine'...
> Spec started
> 
>   MyClass
>   ✓ exists
>   ✓ has a size
> 
>   add()
>     ✓ is a function
>     ✓ increases the size
> 
>   myFunction()
>     ✓ is a function
> 
> Executed 5 of 5 specs SUCCESS in 0.007 sec.
$

问题

是否可以使用gulp运行jasmine-spec-runner,以便在监视任务触发时连续执行?

1 个答案:

答案 0 :(得分:0)

您是否尝试过禁用Karma.conf.js配置文件中的singleRun开关?

singleRun: false

我假设你正在使用Karma

相关问题