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 {
3
3
Browser ,
4
4
BrowserContext ,
5
5
BrowserContextOptions ,
6
+ ConnectOptions ,
7
+ ConnectOverCDPOptions ,
6
8
Page ,
7
9
} from 'playwright-core'
8
10
import { Event } from 'jest-circus'
@@ -68,7 +70,9 @@ const getBrowserPerProcess = async (
68
70
}
69
71
70
72
const options = getBrowserOptions ( browserType , connectOptions )
71
- return playwrightInstance . connect ( options )
73
+ return options && 'endpointURL' in options
74
+ ? playwrightInstance . connectOverCDP ( options )
75
+ : playwrightInstance . connect ( options )
72
76
}
73
77
74
78
const getDeviceConfig = (
Original file line number Diff line number Diff line change @@ -156,9 +156,10 @@ class PlaywrightRunner extends JestRunner {
156
156
typeof browser === 'string'
157
157
? browser
158
158
: generateKey ( browser . name , browserConfig )
159
+ const browserOptions = getBrowserOptions ( browserType , connectOptions )
159
160
const wsEndpoint : WsEndpointType = await this . launchServer (
160
161
browserConfig ,
161
- getBrowserOptions ( browserType , connectOptions ) ? .wsEndpoint || null ,
162
+ 'wsEndpoint' in browserOptions ? browserOptions . wsEndpoint : null ,
162
163
browserType ,
163
164
key ,
164
165
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'
2
2
3
3
export const IMPORT_KIND_PLAYWRIGHT = 'playwright'
4
4
@@ -15,7 +15,7 @@ export const SERVER = 'SERVER'
15
15
export const DEFAULT_CONFIG : JestPlaywrightConfig = {
16
16
launchType : SERVER ,
17
17
launchOptions : { } ,
18
- connectOptions : { } as ConnectOptions ,
18
+ connectOptions : { } as JestPlaywrightConfig [ 'connectOptions' ] ,
19
19
contextOptions : { } ,
20
20
browsers : [ CHROMIUM ] ,
21
21
exitOnPageError : true ,
Original file line number Diff line number Diff line change 4
4
Page ,
5
5
BrowserContextOptions ,
6
6
LaunchOptions ,
7
+ ConnectOptions ,
8
+ ConnectOverCDPOptions ,
7
9
BrowserType as PlaywrightBrowserType ,
8
10
ViewportSize ,
9
11
ChromiumBrowser ,
@@ -191,8 +193,6 @@ type LaunchType = typeof LAUNCH | typeof SERVER | typeof PERSISTENT
191
193
192
194
type Options < T > = T & Partial < Record < BrowserType , T > >
193
195
194
- export type ConnectOptions = Parameters < GenericBrowser [ 'connect' ] > [ 0 ]
195
-
196
196
export type ServerOptions = JestProcessManagerOptions & {
197
197
teardown ?: string
198
198
}
@@ -203,7 +203,7 @@ export interface JestPlaywrightConfig {
203
203
debugOptions ?: JestPlaywrightConfig
204
204
launchType ?: LaunchType
205
205
launchOptions ?: Options < LaunchOptions >
206
- connectOptions ?: Options < ConnectOptions >
206
+ connectOptions ?: Options < ConnectOptions | ConnectOverCDPOptions >
207
207
contextOptions ?: Options < BrowserContextOptions >
208
208
userDataDir ?: string
209
209
exitOnPageError ?: boolean
You can’t perform that action at this time.
0 commit comments