Skip to content

Commit a2c7916

Browse files
committed
FI-1344 refactor: Playwright config (use object)
refactor: reexport `devices` from `@playwright/test`
1 parent 25b6186 commit a2c7916

File tree

4 files changed

+23
-40
lines changed

4 files changed

+23
-40
lines changed

src/config.ts

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {isLocalRun} from './configurator';
2525

2626
import type {FullPackConfig, Mutable, UserlandPack} from './types/internal';
2727

28-
import {defineConfig} from '@playwright/test';
28+
import {defineConfig, type PlaywrightTestConfig} from '@playwright/test';
2929

3030
const maxTimeoutInMs = 3600_000;
3131

@@ -91,6 +91,23 @@ if (isDebug) {
9191
setReadonlyProperty(userlandPack, 'testTimeout', maxTimeoutInMs);
9292
}
9393

94+
const useOptions: PlaywrightTestConfig['use'] = {
95+
actionTimeout: userlandPack.testIdleTimeout,
96+
browserName: userlandPack.browserName,
97+
// eslint-disable-next-line @typescript-eslint/naming-convention
98+
bypassCSP: true,
99+
deviceScaleFactor: userlandPack.deviceScaleFactor,
100+
hasTouch: userlandPack.enableTouchEventEmulation,
101+
headless: isLocalRun ? userlandPack.enableHeadlessMode : true,
102+
isMobile: userlandPack.enableMobileDeviceMode,
103+
launchOptions: {args: [...userlandPack.browserFlags]},
104+
navigationTimeout: userlandPack.pageRequestTimeout,
105+
trace: 'retain-on-failure',
106+
userAgent: userlandPack.userAgent,
107+
viewport: {height: userlandPack.viewportHeight, width: userlandPack.viewportWidth},
108+
...userlandPack.overriddenConfigFields?.use,
109+
};
110+
94111
const playwrightConfig = defineConfig({
95112
expect: {timeout: userlandPack.assertionTimeout},
96113

@@ -100,19 +117,7 @@ const playwrightConfig = defineConfig({
100117

101118
outputDir: join(relativePathFromInstalledE2edToRoot, INTERNAL_REPORTS_DIRECTORY_PATH),
102119

103-
projects: [
104-
{
105-
name: userlandPack.browserName,
106-
use: {
107-
browserName: userlandPack.browserName,
108-
deviceScaleFactor: userlandPack.deviceScaleFactor,
109-
hasTouch: userlandPack.enableTouchEventEmulation,
110-
isMobile: userlandPack.enableMobileDeviceMode,
111-
userAgent: userlandPack.userAgent,
112-
viewport: {height: userlandPack.viewportHeight, width: userlandPack.viewportWidth},
113-
},
114-
},
115-
],
120+
projects: [{name: userlandPack.browserName, use: useOptions}],
116121

117122
retries: isLocalRun ? 0 : userlandPack.maxRetriesCountInDocker - 1,
118123

@@ -126,32 +131,7 @@ const playwrightConfig = defineConfig({
126131

127132
...userlandPack.overriddenConfigFields,
128133

129-
use: {
130-
actionTimeout: userlandPack.testIdleTimeout,
131-
132-
browserName: userlandPack.browserName,
133-
134-
// eslint-disable-next-line @typescript-eslint/naming-convention
135-
bypassCSP: true,
136-
137-
deviceScaleFactor: userlandPack.deviceScaleFactor,
138-
139-
hasTouch: userlandPack.enableTouchEventEmulation,
140-
141-
headless: isLocalRun ? userlandPack.enableHeadlessMode : true,
142-
143-
isMobile: userlandPack.enableMobileDeviceMode,
144-
145-
navigationTimeout: userlandPack.pageRequestTimeout,
146-
147-
trace: 'retain-on-failure',
148-
149-
userAgent: userlandPack.userAgent,
150-
151-
viewport: {height: userlandPack.viewportHeight, width: userlandPack.viewportWidth},
152-
153-
...userlandPack.overriddenConfigFields?.use,
154-
},
134+
use: useOptions,
155135
});
156136

157137
const config: FullPackConfig = Object.assign(playwrightConfig, userlandPack);

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
export {ApiRoute} from './ApiRoute';
55
export {Page} from './Page';
66
export {PageRoute} from './PageRoute';
7+
export {devices} from './playwright';
78
export {Route} from './Route';
89
export {getPlaywrightPage, useContext} from './useContext';
910

src/playwright.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {devices} from '@playwright/test';

src/utils/fullMocks/enableFullMocks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const enableFullMocks = async (
5252
requestKinds: Object.fromEntries(
5353
Object.entries(testFullMocks).map(([key, value]) => [key, value.length]),
5454
),
55+
testId: fullMocksState.testId,
5556
},
5657
LogEventType.InternalUtil,
5758
);

0 commit comments

Comments
 (0)