Skip to content

Commit

Permalink
add option to run tests in a specific file (prebid#1727)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
thewizarodofoz authored and mattpr committed Oct 31, 2017
1 parent bae3886 commit c2e0794
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<path-to-test-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) {
Expand All @@ -186,8 +187,9 @@ gulp.task('test', ['clean'], function (done) {
new KarmaServer(karmaConf, newKarmaCallback(done)).start();
});

// If --file "<path-to-test-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.
Expand Down
4 changes: 2 additions & 2 deletions karma.conf.maker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c2e0794

Please sign in to comment.