UNPKG

mew-time

Version:
49 lines (42 loc) 1.15 kB
import path from "path"; import gulp from "gulp"; import karma from "karma"; import webpackTestConfig from "../config/webpack_test.conf"; gulp.task("single-run", singleRun); gulp.task("auto-watch", autoWatch); function getFiles() { const file = APP.path.test("index.js"); return { files: [file], preprocessors: { [file]: ["webpack", "sourcemap"] } }; } function singleRun(done) { const karmaServer = new karma.Server( Object.assign(webpackTestConfig(), getFiles(), { singleRun: true, autoWatch: false, reporters: ["mocha"] }), karmaFinishHandler(done) ); karmaServer.start(); } function autoWatch(done) { const karmaServer = new karma.Server( Object.assign(webpackTestConfig(), getFiles(), { singleRun: false, autoWatch: true, reporters: ["mocha"] }), karmaFinishHandler(done) ); karmaServer.start(); } function karmaFinishHandler(done) { return failCount => { done(failCount ? new Error(`Failed ${failCount} tests.`) : null); }; }