Tests: migrate testing infrastructure to minimal dependencies
[jquery.git] / test / runner / selenium / runSelenium.js
blob247cd8472e0984bf2b5f9519701c292b2bfc819f
1 import chalk from "chalk";
2 import createDriver from "./createDriver.js";
4 export async function runSelenium(
5         url,
6         { browser },
7         { debug, headless, verbose } = {}
8 ) {
9         if ( debug && headless ) {
10                 throw new Error( "Cannot debug in headless mode." );
11         }
13         const driver = await createDriver( {
14                 browserName: browser,
15                 headless,
16                 verbose
17         } );
19         try {
20                 await driver.get( url );
21                 await driver.executeScript(
22 `return new Promise( ( resolve ) => {
23         QUnit.on( "runEnd", resolve );
24 } )`
25                 );
26         } finally {
27                 if ( !debug || headless ) {
28                         await driver.quit();
29                 }
30         }