Skip to content

Commit badd7b0

Browse files
committed
chore(tests): added websocket to global when not already done (nodejs20)
1 parent e5e9138 commit badd7b0

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

test/setup.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
"use strict";
22

33
/**
4-
* Ensure a global XMLHttpRequest binding exists so strict-mode tests can
5-
* reassign it without throwing ReferenceError in Node.
4+
* Ensure global bindings exist so strict-mode tests can reassign them
5+
* without throwing ReferenceError in Node.
66
*/
77
if (typeof global.XMLHttpRequest === "undefined") {
88
global.XMLHttpRequest = undefined;
99
}
10+
11+
// Define a writable global binding for WebSocket when Node does not provide one
12+
if (typeof WebSocket === "undefined") {
13+
/* eslint-disable no-var */
14+
var WebSocket = undefined; // creates the global binding
15+
/* eslint-enable no-var */
16+
}

0 commit comments

Comments
 (0)