Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(types): fix type generation to make ts tests work (#3385)
Joel Einbinder55a78482e404
diff --git a/utils/generate_types/index.js b/utils/generate_types/index.jsindex 943e41f098..f727dc275d 100644--- a/utils/generate_types/index.js+++ b/utils/generate_types/index.js@@ -177,7 +177,7 @@ function classBody(classDesc) {for (const {eventName, params, comment, type} of eventDescriptions) {if (comment)parts.push(writeComment(comment, ' '));- parts.push(` ${member.name}(event: '${eventName}', optionsOrPredicate?: { predicate?: (${params}) => boolean, timeout?: number }): Promise<${type}>;\n`);+ parts.push(` ${member.name}(event: '${eventName}', optionsOrPredicate?: { predicate?: (${params}) => boolean, timeout?: number } | ((${params}) => boolean)): Promise<${type}>;\n`);}return parts.join('\n');@@ -232,6 +232,9 @@ function writeComment(comment, indent = '') {function typeToString(type, ...namespace) {if (!type)return 'void';+ // Accessibility.snapshot has a recursive data structure, so special case it here.+ if (namespace[0] === 'AccessibilitySnapshot' && namespace[1] === 'children')+ return 'Array<AccessibilitySnapshot>';let typeString = stringifyType(parseType(type.name));if (type.properties.length && typeString.indexOf('Object') !== -1) {const name = namespace.map(n => n[0].toUpperCase() + n.substring(1)).join('');diff --git a/utils/generate_types/test/test.ts b/utils/generate_types/test/test.tsindex 4df9cecd3a..963cbf3390 100644--- a/utils/generate_types/test/test.ts+++ b/utils/generate_types/test/test.ts@@ -399,6 +399,10 @@ playwright.chromium.launch().then(async browser => {});const assertion: AssertType<playwright.Page, typeof newPage> = true;}+ {+ const response = await page.waitForEvent('response', response => response.url() === 'asdf');+ const assertion: AssertType<playwright.Response, typeof response> = true;+ }})();// typed handles