有可能把gulp watch和jasmine-spec-reporter结合起来吗?

Is it possible to combine gulp watch with jasmine-spec-reporter

本文关键字:结合 起来 jasmine-spec-reporter gulp watch 有可能      更新时间:2023-09-26

我正在尝试将手表与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,它工作正常,但如果我运行watch任务,它只执行一次:

$ 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,以便在watch任务触发时连续执行?

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

singleRun: false

我假设你使用的是Karma