From 0d840ef1173d80dbf455e27bd96cf40d3b0aae37 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Tue, 30 Nov 2021 09:13:12 -0800 Subject: [PATCH] Build system: improve build for development workflow This adds a "test-only" gulp task that runs only tests (without clean/lint) and makes the single-spec test environment consistent with the whole-suite case. --- gulpfile.js | 3 ++- karma.conf.maker.js | 2 +- test/helpers/prebidGlobal.js | 1 + test/test_deps.js | 3 +++ test/test_index.js | 4 +--- 5 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 test/test_deps.js diff --git a/gulpfile.js b/gulpfile.js index c86357372f1..34103b25be2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -389,7 +389,8 @@ gulp.task('build-bundle-dev', gulp.series(makeDevpackPkg, gulpBundle.bind(null, gulp.task('build-bundle-prod', gulp.series(makeWebpackPkg, gulpBundle.bind(null, false))); // public tasks (dependencies are needed for each task since they can be ran on their own) -gulp.task('test', gulp.series(clean, lint, test)); +gulp.task('test-only', test); +gulp.task('test', gulp.series(clean, lint, 'test-only')); gulp.task('test-coverage', gulp.series(clean, testCoverage)); gulp.task(viewCoverage); diff --git a/karma.conf.maker.js b/karma.conf.maker.js index abff3f043b9..be51947dae8 100644 --- a/karma.conf.maker.js +++ b/karma.conf.maker.js @@ -111,7 +111,7 @@ module.exports = function(codeCoverage, browserstack, watchMode, file) { var webpackConfig = newWebpackConfig(codeCoverage); var plugins = newPluginsArray(browserstack); - var files = file ? ['test/helpers/prebidGlobal.js', file] : ['test/test_index.js']; + var files = file ? ['test/test_deps.js', file] : ['test/test_index.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. if (watchMode) { diff --git a/test/helpers/prebidGlobal.js b/test/helpers/prebidGlobal.js index 597076ab0db..94776a5242b 100644 --- a/test/helpers/prebidGlobal.js +++ b/test/helpers/prebidGlobal.js @@ -1,3 +1,4 @@ window.$$PREBID_GLOBAL$$ = (window.$$PREBID_GLOBAL$$ || {}); +window.$$PREBID_GLOBAL$$.installedModules = (window.$$PREBID_GLOBAL$$.installedModules || []); window.$$PREBID_GLOBAL$$.cmd = window.$$PREBID_GLOBAL$$.cmd || []; window.$$PREBID_GLOBAL$$.que = window.$$PREBID_GLOBAL$$.que || []; diff --git a/test/test_deps.js b/test/test_deps.js new file mode 100644 index 00000000000..e535154b799 --- /dev/null +++ b/test/test_deps.js @@ -0,0 +1,3 @@ +require('test/helpers/prebidGlobal.js'); +require('test/mocks/adloaderStub.js'); +require('test/mocks/xhr.js'); diff --git a/test/test_index.js b/test/test_index.js index 53d75e36176..883f4d0590c 100644 --- a/test/test_index.js +++ b/test/test_index.js @@ -1,6 +1,4 @@ -require('test/helpers/prebidGlobal.js'); -require('test/mocks/adloaderStub.js'); -require('test/mocks/xhr.js'); +require('./test_deps.js'); var testsContext = require.context('.', true, /_spec$/); testsContext.keys().forEach(testsContext);