From 19deb8eb37bd95603c2a16cd435859a822b23beb Mon Sep 17 00:00:00 2001 From: Oz Weiss Date: Tue, 24 Oct 2017 20:00:20 +0300 Subject: [PATCH] add option to run tests in a specific file (#1727) * add option to run tests in a specific file * add option to run tests in a specific file * Update gulpfile.js * Update karma.conf.maker.js --- gulpfile.js | 6 ++++-- karma.conf.maker.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index f80cfe91d34..d7a151ce357 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -173,10 +173,11 @@ gulp.task('webpack', ['clean'], function () { // By default, this runs in headless chrome. // // If --watch is given, the task will re-run unit tests whenever the source code changes +// If --file "" is given, the task will only run tests in the specified file. // If --browserstack is given, it will run the full suite of currently supported browsers. // If --browsers is given, browsers can be chosen explicitly. e.g. --browsers=chrome,firefox,ie9 gulp.task('test', ['clean'], function (done) { - var karmaConf = karmaConfMaker(false, argv.browserstack, argv.watch); + var karmaConf = karmaConfMaker(false, argv.browserstack, argv.watch, argv.file); var browserOverride = helpers.parseBrowserArgs(argv).map(helpers.toCapitalCase); if (browserOverride.length > 0) { @@ -186,8 +187,9 @@ gulp.task('test', ['clean'], function (done) { new KarmaServer(karmaConf, newKarmaCallback(done)).start(); }); +// If --file "" is given, the task will only run tests in the specified file. gulp.task('test-coverage', ['clean'], function(done) { - new KarmaServer(karmaConfMaker(true, false), newKarmaCallback(done)).start(); + new KarmaServer(karmaConfMaker(true, false, argv.file), newKarmaCallback(done)).start(); }); // View the code coverage report in the browser. diff --git a/karma.conf.maker.js b/karma.conf.maker.js index aad6a7d7c1d..d2b1d49e081 100644 --- a/karma.conf.maker.js +++ b/karma.conf.maker.js @@ -92,12 +92,12 @@ function setBrowsers(karmaConf, browserstack) { } } -module.exports = function(codeCoverage, browserstack, watchMode) { +module.exports = function(codeCoverage, browserstack, watchMode, file) { var webpackConfig = newWebpackConfig(codeCoverage); var plugins = newPluginsArray(browserstack); var files = [ 'test/helpers/prebidGlobal.js', - 'test/**/*_spec.js' + file ? file : 'test/**/*_spec.js' ]; // This file opens the /debug.html tab automatically. // It has no real value unless you're running --watch, and intend to do some debugging in the browser.