From f9cb0dd5b328f7e87ce39f49816dea3d38674a02 Mon Sep 17 00:00:00 2001 From: Matt Probert Date: Tue, 28 Nov 2017 14:00:02 -0600 Subject: [PATCH] Randomize pbjs global name when testing (#1787) * Fix test that hard-coded pbjs global. * Randomize pbjs global name when testing. Causes tests that hard-code global name to break. --- karma.conf.maker.js | 2 +- webpack.conf.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/karma.conf.maker.js b/karma.conf.maker.js index d2b1d49e081..98148e565d3 100644 --- a/karma.conf.maker.js +++ b/karma.conf.maker.js @@ -1,7 +1,7 @@ // This configures Karma, describing how to run the tests and where to output code coverage reports. // // For more information, see http://karma-runner.github.io/1.0/config/configuration-file.html - +process.env.test = true; var _ = require('lodash'); var webpackConf = require('./webpack.conf'); var path = require('path') diff --git a/webpack.conf.js b/webpack.conf.js index 38f4e5dadd7..9f42fe46701 100644 --- a/webpack.conf.js +++ b/webpack.conf.js @@ -10,6 +10,8 @@ var neverBundle = [ 'AnalyticsAdapter.js' ]; +var prebidGlobalName = process.env.test ? 'pbjs_' + Math.floor(Math.random() * 10000) : prebid.globalVarName; + module.exports = { devtool: 'source-map', resolve: { @@ -77,7 +79,7 @@ module.exports = { { pattern: /\$\$PREBID_GLOBAL\$\$/g, replacement: function (match, p1, offset, string) { - return prebid.globalVarName; + return prebidGlobalName; } } ]