Skip to content

Commit 484c7db

Browse files
committed
Use Proxy for _VSCODE_NODE_MODULES
Instead of deleting the complete `_VSCODE_NODE_MODULES` object, we now use a `Proxy` to intercept the `_isMockFunction` property. This is safer and will not delete a global variable that VSCode expects to exist.
1 parent 1ea3cfd commit 484c7db

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

extensions/ql-vscode/patches/jest-runner-vscode+3.0.1.patch

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/node_modules/jest-runner-vscode/dist/child/environment.js b/node_modules/jest-runner-vscode/dist/child/environment.js
2-
index 1ac28d5..52665c7 100644
2+
index 1ac28d5..f91f216 100644
33
--- a/node_modules/jest-runner-vscode/dist/child/environment.js
44
+++ b/node_modules/jest-runner-vscode/dist/child/environment.js
5-
@@ -10,6 +10,14 @@ const wrap_io_1 = __importDefault(require("./wrap-io"));
5+
@@ -10,6 +10,21 @@ const wrap_io_1 = __importDefault(require("./wrap-io"));
66
const load_pnp_1 = __importDefault(require("./load-pnp"));
77
const ipc = new ipc_client_1.default('env');
88
class VSCodeEnvironment extends jest_environment_node_1.default {
@@ -11,7 +11,14 @@ index 1ac28d5..52665c7 100644
1111
+ // The _VSCODE_NODE_MODULES is a proxy which will require a module if any property
1212
+ // on it is accessed. This is a workaround for the fact that jest will call
1313
+ // _isMockFunction on the module, which will cause that function to be required.
14-
+ delete this.global._VSCODE_NODE_MODULES;
14+
+ this.global._VSCODE_NODE_MODULES = new Proxy(this.global._VSCODE_NODE_MODULES, {
15+
+ get(target, prop) {
16+
+ if (prop === '_isMockFunction') {
17+
+ return undefined;
18+
+ }
19+
+ return target[prop];
20+
+ },
21+
+ });
1522
+ }
1623
+
1724
async setup() {

0 commit comments

Comments
 (0)