Skip to content

Commit f9ac6a5

Browse files
committed
Only load JSDom if needed
This is a temporary fix for regular expression errors
1 parent d84dbd8 commit f9ac6a5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/app/src/sandbox/eval/tests/jest-lite.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,15 @@ function addScript(src: string) {
4545
});
4646
}
4747

48+
let jsdomPromise = null;
4849
/**
4950
* Load JSDOM while the sandbox loads. Before we run a test we make sure that this has been loaded.
5051
*/
51-
const jsdomPromise = addScript('/static/js/jsdom-4.0.0.min.js');
52+
const getJSDOM = () => {
53+
jsdomPromise = jsdomPromise || addScript('/static/js/jsdom-4.0.0.min.js');
54+
55+
return jsdomPromise;
56+
};
5257

5358
function resetTestState() {
5459
const ROOT_DESCRIBE_BLOCK = makeDescribe(ROOT_DESCRIBE_BLOCK_NAME);
@@ -220,7 +225,7 @@ export default class TestRunner {
220225
return;
221226
}
222227

223-
await jsdomPromise;
228+
await getJSDOM();
224229

225230
this.sendMessage('total_test_start');
226231

0 commit comments

Comments
 (0)