Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix: devices is a map not an array (#16729)

Yury Semikhatskyb51b7e7f67d1
diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts
index b7ece2c2f2..5cb58c64f8 100644
--- a/packages/playwright-core/types/types.d.ts
+++ b/packages/playwright-core/types/types.d.ts
@@ -11182,7 +11182,7 @@ type AccessibilityNode = {
children?: AccessibilityNode[];
}
-export const devices: Devices & DeviceDescriptor[];
+export const devices: Devices;
//@ts-ignore this will be any if electron is not installed
type ElectronType = typeof import('electron');
diff --git a/utils/generate_types/overrides.d.ts b/utils/generate_types/overrides.d.ts
index 4c9ab930dc..760954e0c8 100644
--- a/utils/generate_types/overrides.d.ts
+++ b/utils/generate_types/overrides.d.ts
@@ -232,7 +232,7 @@ type AccessibilityNode = {
children?: AccessibilityNode[];
}
-export const devices: Devices & DeviceDescriptor[];
+export const devices: Devices;
//@ts-ignore this will be any if electron is not installed
type ElectronType = typeof import('electron');
diff --git a/utils/generate_types/test/test.ts b/utils/generate_types/test/test.ts
index 0f26e3c8fe..00be3d3e06 100644
--- a/utils/generate_types/test/test.ts
+++ b/utils/generate_types/test/test.ts
@@ -775,7 +775,7 @@ playwright.chromium.launch().then(async browser => {
const isMobileAssertion: AssertType<boolean, typeof iPhone.isMobile> = true;
}
{
- const agents = playwright.devices.map(x => x.userAgent);
+ const agents = Object.entries(playwright.devices).map(([name, descriptor]) => descriptor.userAgent);
const assertion: AssertType<string[], typeof agents> = true;
}