@@ -4,9 +4,10 @@ import { startDriver } from './webdriver';
44import { WebDriver } from 'selenium-webdriver' ;
55import chromedriver from 'chromedriver' ;
66import chrome from 'selenium-webdriver/chrome' ;
7- import type { Options } from 'selenium-webdriver/chrome' ;
87import path from 'path' ;
98import { WebdriverConfigParams } from '../types' ;
9+ import sinon from 'sinon' ;
10+
1011describe ( 'startDriver' , ( ) => {
1112 let config : WebdriverConfigParams ;
1213 let browser : string ;
@@ -22,7 +23,11 @@ describe('startDriver', () => {
2223 } ) ;
2324
2425 afterEach ( async ( ) => {
25- await driver . quit ( ) ;
26+ // try catch required due to `chrome.options` being mocked with sinon
27+ // and not properly creating a driver
28+ try {
29+ await driver . quit ( ) ;
30+ } catch ( error ) { }
2631 } ) ;
2732
2833 it ( 'creates a driver' , async ( ) => {
@@ -101,4 +106,18 @@ describe('startDriver', () => {
101106 assert . isObject ( timeoutValue ) ;
102107 assert . deepEqual ( timeoutValue . script , 10000000 ) ;
103108 } ) ;
109+
110+ it ( 'invokes `options.headless()` on versions of selenium-webdriver < 4.17.0' , async ( ) => {
111+ const stub = sinon . stub ( chrome , 'Options' ) . returns ( {
112+ headless : ( ) => { }
113+ } ) ;
114+
115+ // try catch required due to `chrome.options` being mocked with sinon
116+ // and not properly creating a driver
117+ try {
118+ driver = await startDriver ( config ) ;
119+ } catch ( error ) { }
120+ assert . isTrue ( stub . calledOnce ) ;
121+ stub . restore ( ) ;
122+ } ) ;
104123} ) ;
0 commit comments