Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add ability to config debugOptions with jest-playwright.config #266

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/PlaywrightEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export const getPlaywrightEnv = (basicEnv = 'node'): unknown => {
exitOnPageError,
selectors,
launchType,
debugOptions,
} = this._jestPlaywrightConfig
if (wsEndpoint && !connectOptions?.wsEndpoint) {
this._jestPlaywrightConfig.connectOptions = {
Expand Down Expand Up @@ -184,18 +185,24 @@ export const getPlaywrightEnv = (basicEnv = 'node'): unknown => {
let resultBrowserConfig: JestPlaywrightConfig
let resultContextOptions: BrowserContextOptions | undefined
if (isDebug) {
resultBrowserConfig = config
resultContextOptions = config.contextOptions
resultBrowserConfig = debugOptions
? deepMerge(config, debugOptions)
: config
resultContextOptions =
debugOptions && debugOptions.contextOptions
? deepMerge(
config.contextOptions!,
debugOptions.contextOptions!,
)
: config.contextOptions
} else {
resultBrowserConfig = deepMerge(this._jestPlaywrightConfig, {
...config,
launchType: LAUNCH,
})
resultBrowserConfig = deepMerge(this._jestPlaywrightConfig, config)
resultContextOptions = {
...this._jestPlaywrightConfig.contextOptions,
...config.contextOptions,
}
}
resultBrowserConfig.launchType = LAUNCH
const browser = await getBrowserPerProcess(
playwrightInstance,
browserType,
Expand Down
1 change: 1 addition & 0 deletions types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ type Options<T> = T & Partial<Record<BrowserType, T>>
export type ConnectOptions = Parameters<GenericBrowser['connect']>[0]

export interface JestPlaywrightConfig {
debugOptions?: JestPlaywrightConfig
launchType?: LaunchType
launchOptions?: Options<LaunchOptions>
connectOptions?: Options<ConnectOptions>
Expand Down