|
1 | 1 | /* eslint-disable no-console */
|
2 | 2 | import type { Event, State } from 'jest-circus'
|
3 |
| -import type { Browser, Page, BrowserContext } from 'playwright-core' |
| 3 | +import type { |
| 4 | + Browser, |
| 5 | + Page, |
| 6 | + BrowserContext, |
| 7 | + BrowserContextOptions, |
| 8 | +} from 'playwright-core' |
4 | 9 | import type {
|
5 | 10 | JestPlaywrightConfig,
|
6 | 11 | GenericBrowser,
|
@@ -167,20 +172,37 @@ export const getPlaywrightEnv = (basicEnv = 'node'): unknown => {
|
167 | 172 | this.global.jestPlaywright = {
|
168 | 173 | _configSeparateEnv: async (
|
169 | 174 | config: JestPlaywrightConfig,
|
| 175 | + isDebug?: boolean, |
170 | 176 | ): Promise<ConfigParams> => {
|
171 |
| - const { contextOptions, launchType } = config |
| 177 | + const { contextOptions, launchOptions, launchType } = config |
| 178 | + let resultBrowserConfig: JestPlaywrightConfig |
| 179 | + let resultContextOptions: BrowserContextOptions | undefined |
| 180 | + if (isDebug) { |
| 181 | + resultBrowserConfig = config |
| 182 | + resultContextOptions = contextOptions |
| 183 | + } else { |
| 184 | + resultBrowserConfig = { |
| 185 | + ...this._jestPlaywrightConfig, |
| 186 | + launchType, |
| 187 | + launchOptions: { |
| 188 | + ...this._jestPlaywrightConfig.launchOptions, |
| 189 | + ...launchOptions, |
| 190 | + }, |
| 191 | + } |
| 192 | + resultContextOptions = { |
| 193 | + ...this._jestPlaywrightConfig.contextOptions, |
| 194 | + ...contextOptions, |
| 195 | + } |
| 196 | + } |
172 | 197 | const browserOrContext = await getBrowserPerProcess(
|
173 | 198 | playwrightInstance,
|
174 | 199 | browserType,
|
175 |
| - { |
176 |
| - ...this._jestPlaywrightConfig, |
177 |
| - ...config, |
178 |
| - }, |
| 200 | + resultBrowserConfig, |
179 | 201 | )
|
180 | 202 | const browser = launchType === PERSISTENT ? null : browserOrContext
|
181 | 203 | const newContextOptions = getBrowserOptions(
|
182 | 204 | browserName,
|
183 |
| - contextOptions, |
| 205 | + resultContextOptions, |
184 | 206 | )
|
185 | 207 | const context =
|
186 | 208 | launchType === PERSISTENT
|
|
0 commit comments