aboutsummaryrefslogtreecommitdiffstats
path: root/test/runner/jsdom/createWindow.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/runner/jsdom/createWindow.js')
-rw-r--r--test/runner/jsdom/createWindow.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/runner/jsdom/createWindow.js b/test/runner/jsdom/createWindow.js
new file mode 100644
index 000000000..de6c63ffa
--- /dev/null
+++ b/test/runner/jsdom/createWindow.js
@@ -0,0 +1,21 @@
+import jsdom from "jsdom";
+
+const { JSDOM } = jsdom;
+
+export default async function createWindow( { reportId, url, verbose } ) {
+ const virtualConsole = new jsdom.VirtualConsole();
+ virtualConsole.sendTo( console );
+ virtualConsole.removeAllListeners( "clear" );
+
+ const { window } = await JSDOM.fromURL( url, {
+ resources: "usable",
+ runScripts: "dangerously",
+ virtualConsole
+ } );
+
+ if ( verbose ) {
+ console.log( `JSDOM window created (${ reportId })` );
+ }
+
+ return window;
+}