aboutsummaryrefslogtreecommitdiffstats
path: root/test/runner/jsdom.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/runner/jsdom.js')
-rw-r--r--test/runner/jsdom.js55
1 files changed, 0 insertions, 55 deletions
diff --git a/test/runner/jsdom.js b/test/runner/jsdom.js
deleted file mode 100644
index d9ff9dda7..000000000
--- a/test/runner/jsdom.js
+++ /dev/null
@@ -1,55 +0,0 @@
-import jsdom from "jsdom";
-
-const { JSDOM } = jsdom;
-
-const windows = Object.create( null );
-
-export async function runJSDOM( url, { reportId, 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 opened.", reportId );
- }
- windows[ reportId ] = window;
-
- return new Promise( ( resolve ) => {
- window.finish = resolve;
- } );
-}
-
-export function cleanupJSDOM( reportId, { verbose } ) {
- const window = windows[ reportId ];
- if ( window ) {
- if ( window.finish ) {
- window.finish();
- }
- window.close();
- delete windows[ reportId ];
- if ( verbose ) {
- console.log( "Closed JSDOM window.", reportId );
- }
- }
-}
-
-export function cleanupAllJSDOM( { verbose } ) {
- const windowsRemaining = Object.keys( windows ).length;
- if ( windowsRemaining ) {
- if ( verbose ) {
- console.log(
- `Cleaning up ${ windowsRemaining } JSDOM window${
- windowsRemaining > 1 ? "s" : ""
- }...`
- );
- }
- for ( const id in windows ) {
- cleanupJSDOM( id, { verbose } );
- }
- }
-}