Remove $$PREBID_GLOBAL$$ from unit tests
The $$PREBID_GLOBAL$$ references are causing a few problems in our test code.
First, they're fragile. #1437 was logged about this, and in the time it took to fix the existing references, several more PRs got merged which broke them again.
Second, they cause weird behavior. #1427 surfaced an issue where a test passed when using config.setConfig, but failed when using $$PREBID_GLOBAL$$.setConfig--even though they're the same function. I traced the root problem to the use of window. Currently, our webpack preprocessor is making a new bundle of Prebid for every unit test file... but the window object (and therefore $$PREBID_GLOBAL$$) persists across files. This is a very subtle bug which makes writing good unit tests tricky.
Lastly, they prevent us from improving our unit test performance. Due to the window issue, many tests surrounding $$PREBID_GLOBAL$$ fail if we do change the way we bundle the code for testing. It's unfortunate, because the unit tests would only take ~15s to complete (rather than the ~45s they take currently). This difference will only increase as we add new unit test files.
We should refactor our code to be more testable, and remove all $$PREBID_GLOBAL$$ references from the existing tests.
Fixing this will be a marathon, not a sprint.
My proposal for working towards a solution is outlined in #1510. By encapsulating $$PREBID_GLOBAL$$ state into smaller objects, and injecting those objects as dependencies throughout most of the code, we will gradually work towards a codebase which does not rely on $$PREBID_GLOBAL$$ for testing.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.