This repository was archived by the owner on Sep 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +12
-7
lines changed Expand file tree Collapse file tree 4 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import type {
33 Browser ,
44 BrowserContext ,
55 BrowserContextOptions ,
6+ ConnectOptions ,
7+ ConnectOverCDPOptions ,
68 Page ,
79} from 'playwright-core'
810import { Event } from 'jest-circus'
@@ -68,7 +70,9 @@ const getBrowserPerProcess = async (
6870 }
6971
7072 const options = getBrowserOptions ( browserType , connectOptions )
71- return playwrightInstance . connect ( options )
73+ return options && 'endpointURL' in options
74+ ? playwrightInstance . connectOverCDP ( options )
75+ : playwrightInstance . connect ( options )
7276}
7377
7478const getDeviceConfig = (
Original file line number Diff line number Diff line change @@ -156,9 +156,10 @@ class PlaywrightRunner extends JestRunner {
156156 typeof browser === 'string'
157157 ? browser
158158 : generateKey ( browser . name , browserConfig )
159+ const browserOptions = getBrowserOptions ( browserType , connectOptions )
159160 const wsEndpoint : WsEndpointType = await this . launchServer (
160161 browserConfig ,
161- getBrowserOptions ( browserType , connectOptions ) ? .wsEndpoint || null ,
162+ 'wsEndpoint' in browserOptions ? browserOptions . wsEndpoint : null ,
162163 browserType ,
163164 key ,
164165 instance as GenericBrowser ,
Original file line number Diff line number Diff line change 1- import type { JestPlaywrightConfig , ConnectOptions } from '../types/global'
1+ import type { JestPlaywrightConfig } from '../types/global'
22
33export const IMPORT_KIND_PLAYWRIGHT = 'playwright'
44
@@ -15,7 +15,7 @@ export const SERVER = 'SERVER'
1515export const DEFAULT_CONFIG : JestPlaywrightConfig = {
1616 launchType : SERVER ,
1717 launchOptions : { } ,
18- connectOptions : { } as ConnectOptions ,
18+ connectOptions : { } as JestPlaywrightConfig [ 'connectOptions' ] ,
1919 contextOptions : { } ,
2020 browsers : [ CHROMIUM ] ,
2121 exitOnPageError : true ,
Original file line number Diff line number Diff line change 44 Page ,
55 BrowserContextOptions ,
66 LaunchOptions ,
7+ ConnectOptions ,
8+ ConnectOverCDPOptions ,
79 BrowserType as PlaywrightBrowserType ,
810 ViewportSize ,
911 ChromiumBrowser ,
@@ -191,8 +193,6 @@ type LaunchType = typeof LAUNCH | typeof SERVER | typeof PERSISTENT
191193
192194type Options < T > = T & Partial < Record < BrowserType , T > >
193195
194- export type ConnectOptions = Parameters < GenericBrowser [ 'connect' ] > [ 0 ]
195-
196196export type ServerOptions = JestProcessManagerOptions & {
197197 teardown ?: string
198198}
@@ -203,7 +203,7 @@ export interface JestPlaywrightConfig {
203203 debugOptions ?: JestPlaywrightConfig
204204 launchType ?: LaunchType
205205 launchOptions ?: Options < LaunchOptions >
206- connectOptions ?: Options < ConnectOptions >
206+ connectOptions ?: Options < ConnectOptions | ConnectOverCDPOptions >
207207 contextOptions ?: Options < BrowserContextOptions >
208208 userDataDir ?: string
209209 exitOnPageError ?: boolean
You can’t perform that action at this time.
0 commit comments