diff --git a/src/config.ts b/src/config.ts index c0f7a386..ca23b004 100644 --- a/src/config.ts +++ b/src/config.ts @@ -25,7 +25,7 @@ import {isLocalRun} from './configurator'; import type {FullPackConfig, Mutable, UserlandPack} from './types/internal'; -import {defineConfig} from '@playwright/test'; +import {defineConfig, type PlaywrightTestConfig} from '@playwright/test'; const maxTimeoutInMs = 3600_000; @@ -91,6 +91,23 @@ if (isDebug) { setReadonlyProperty(userlandPack, 'testTimeout', maxTimeoutInMs); } +const useOptions: PlaywrightTestConfig['use'] = { + actionTimeout: userlandPack.testIdleTimeout, + browserName: userlandPack.browserName, + // eslint-disable-next-line @typescript-eslint/naming-convention + bypassCSP: true, + deviceScaleFactor: userlandPack.deviceScaleFactor, + hasTouch: userlandPack.enableTouchEventEmulation, + headless: isLocalRun ? userlandPack.enableHeadlessMode : true, + isMobile: userlandPack.enableMobileDeviceMode, + launchOptions: {args: [...userlandPack.browserFlags]}, + navigationTimeout: userlandPack.pageRequestTimeout, + trace: 'retain-on-failure', + userAgent: userlandPack.userAgent, + viewport: {height: userlandPack.viewportHeight, width: userlandPack.viewportWidth}, + ...userlandPack.overriddenConfigFields?.use, +}; + const playwrightConfig = defineConfig({ expect: {timeout: userlandPack.assertionTimeout}, @@ -100,19 +117,7 @@ const playwrightConfig = defineConfig({ outputDir: join(relativePathFromInstalledE2edToRoot, INTERNAL_REPORTS_DIRECTORY_PATH), - projects: [ - { - name: userlandPack.browserName, - use: { - browserName: userlandPack.browserName, - deviceScaleFactor: userlandPack.deviceScaleFactor, - hasTouch: userlandPack.enableTouchEventEmulation, - isMobile: userlandPack.enableMobileDeviceMode, - userAgent: userlandPack.userAgent, - viewport: {height: userlandPack.viewportHeight, width: userlandPack.viewportWidth}, - }, - }, - ], + projects: [{name: userlandPack.browserName, use: useOptions}], retries: isLocalRun ? 0 : userlandPack.maxRetriesCountInDocker - 1, @@ -126,32 +131,7 @@ const playwrightConfig = defineConfig({ ...userlandPack.overriddenConfigFields, - use: { - actionTimeout: userlandPack.testIdleTimeout, - - browserName: userlandPack.browserName, - - // eslint-disable-next-line @typescript-eslint/naming-convention - bypassCSP: true, - - deviceScaleFactor: userlandPack.deviceScaleFactor, - - hasTouch: userlandPack.enableTouchEventEmulation, - - headless: isLocalRun ? userlandPack.enableHeadlessMode : true, - - isMobile: userlandPack.enableMobileDeviceMode, - - navigationTimeout: userlandPack.pageRequestTimeout, - - trace: 'retain-on-failure', - - userAgent: userlandPack.userAgent, - - viewport: {height: userlandPack.viewportHeight, width: userlandPack.viewportWidth}, - - ...userlandPack.overriddenConfigFields?.use, - }, + use: useOptions, }); const config: FullPackConfig = Object.assign(playwrightConfig, userlandPack); diff --git a/src/index.ts b/src/index.ts index 80537c0c..92372e07 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,7 @@ export {ApiRoute} from './ApiRoute'; export {Page} from './Page'; export {PageRoute} from './PageRoute'; +export {devices} from './playwright'; export {Route} from './Route'; export {getPlaywrightPage, useContext} from './useContext'; diff --git a/src/playwright.ts b/src/playwright.ts new file mode 100644 index 00000000..3e452ae3 --- /dev/null +++ b/src/playwright.ts @@ -0,0 +1 @@ +export {devices} from '@playwright/test'; diff --git a/src/utils/fullMocks/enableFullMocks.ts b/src/utils/fullMocks/enableFullMocks.ts index dfc85067..77567cec 100644 --- a/src/utils/fullMocks/enableFullMocks.ts +++ b/src/utils/fullMocks/enableFullMocks.ts @@ -52,6 +52,7 @@ export const enableFullMocks = async ( requestKinds: Object.fromEntries( Object.entries(testFullMocks).map(([key, value]) => [key, value.length]), ), + testId: fullMocksState.testId, }, LogEventType.InternalUtil, );