简短版本:
如何启动Karma并让它在与Karma启动页面相同的浏览器中自动打开debug.html文件?
长版:
我不是使用控制台记录器为Karma的忠实粉丝,所以我一直在使用karma-jasmine-html-reporter-livereload输出到Karma的localhost:9876 / debug.html文件.问题是,每次我开始调试会话时,我都必须单击业力打开的网页中的“调试”按钮.
我想找到一种方法让业力通过gulp任务自动打开debug.html页面.我在多个浏览器中运行测试,因此我希望在每个Karma打开的浏览器中打开debug.html页面作为第二个选项卡.当karma关闭时,我还希望能够关闭该debug.html选项卡.我尝试了很多东西,没有成功.
这是我的gulp任务. ‘watch’任务监视我的源TypeScript文件并将它们编译成javascript ……没什么特别的.
gulp.task('watch-test', ['watch'], function (done) {
//start a livereload server so that the karma html
//reporter knows to reload whenever the scripts change
livereload.listen(35729);
gulp.watch('dist/src/**/*.js').on('change', livereload.changed);
new KarmaServer({
configFile: __dirname + '/karma.conf.js',
singleRun: false
}, done).start();
});