-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
-
Server Serverless 2023-02-06
The core set of libraries included in the test runner (nee "shell") are injected in all new javascript scopes before any test code is run. These libraries define a number of global variables (such as rs, sh, etc) which may be overwritten accidentally by jstests which unintentionally shadow those variables. This has traditionally been avoided by aggressive use of IIFEs in jstests, but part of the process of converting the test corpus to es modules includes unwrapping those IIFE-guarded tests. A solution to this problem is to have the standard libraries always prefix their access of these global variables with globalThis, so that we are guaranteed access of the global variable rather than any lexically scoped, shadowed variant within jstest code.