Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to run tests in a specific file #1727

Merged
merged 4 commits into from
Oct 24, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add this to the test-coverage task?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure


var browserOverride = helpers.parseBrowserArgs(argv).map(helpers.toCapitalCase);
if (browserOverride.length > 0) {
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,10 +92,10 @@ 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 = [
var files = file ? [file] : [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be var files = file ? ['test/helpers/prebidGlobal.js', file] : ...

Otherwise it fails on files which use $$PREBID_GLOBAL$$--even if it's just indirectly, through the import chain. For example, gulp test --file "test/spec/modules/appnexusAstBidAdapter_spec.js" fails because the adapter relies on src/config, which relies on $$PREBID_GLOBAL$$.

This problem should fade away as progress gets made on #1508 and #1510... but for now it's common enough that the gulpfile should probably support it.

'test/helpers/prebidGlobal.js',
'test/**/*_spec.js'
];
Expand Down