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
chore: remove unnecessary casts to any (#36555)
Adam Gastineau39a930573ccf
diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.tsindex c145cf3b63..e2220395fa 100644--- a/packages/playwright/src/index.ts+++ b/packages/playwright/src/index.ts@@ -27,8 +27,10 @@ import { stepTitle } from './util';import type { Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, ScreenshotMode, TestInfo, TestType, VideoMode } from '../types/test';import type { ContextReuseMode } from './common/config';import type { TestInfoImpl, TestStepInternal } from './worker/testInfo';-import type { ClientInstrumentation, ClientInstrumentationListener } from '../../playwright-core/src/client/clientInstrumentation';+import type { ClientInstrumentationListener } from '../../playwright-core/src/client/clientInstrumentation';import type { Playwright as PlaywrightImpl } from '../../playwright-core/src/client/playwright';+import type { Browser as BrowserImpl } from '../../playwright-core/src/client/browser';+import type { BrowserContext as BrowserContextImpl } from '../../playwright-core/src/client/browserContext';import type { APIRequestContext, Browser, BrowserContext, BrowserContextOptions, LaunchOptions, Page, Tracing, Video } from 'playwright-core';export { expect } from './matchers/expect';@@ -110,7 +112,7 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({},});await use(browser);- await (browser as any)._wrapApiCall(async () => {+ await (browser as BrowserImpl)._wrapApiCall(async () => {await browser.close({ reason: 'Test ended.' });}, { internal: true });return;@@ -118,7 +120,7 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({const browser = await playwright[browserName].launch();await use(browser);- await (browser as any)._wrapApiCall(async () => {+ await (browser as BrowserImpl)._wrapApiCall(async () => {await browser.close({ reason: 'Test ended.' });}, { internal: true });}, { scope: 'worker', timeout: 0 }],@@ -318,7 +320,7 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({},};- const clientInstrumentation = (playwright as any)._instrumentation as ClientInstrumentation;+ const clientInstrumentation = (playwright as PlaywrightImpl)._instrumentation;clientInstrumentation.addListener(csiListener);await use();@@ -355,12 +357,12 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({context.on('page', page => contextData.pagesWithVideo.push(page));if (process.env.PW_CLOCK === 'frozen') {- await (context as any)._wrapApiCall(async () => {+ await (context as BrowserContextImpl)._wrapApiCall(async () => {await context.clock.install({ time: 0 });await context.clock.pauseAt(1000);}, { internal: true });} else if (process.env.PW_CLOCK === 'realtime') {- await (context as any)._wrapApiCall(async () => {+ await (context as BrowserContextImpl)._wrapApiCall(async () => {await context.clock.install({ time: 0 });}, { internal: true });}@@ -371,7 +373,7 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({let counter = 0;const closeReason = testInfo.status === 'timedOut' ? 'Test timeout of ' + testInfo.timeout + 'ms exceeded.' : 'Test ended.';await Promise.all([...contexts.keys()].map(async context => {- await (context as any)._wrapApiCall(async () => {+ await (context as BrowserContextImpl)._wrapApiCall(async () => {await context.close({ reason: closeReason });}, { internal: true });const testFailed = testInfo.status !== testInfo.expectedStatus;@@ -413,10 +415,10 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({}const defaultContextOptions = (playwright.chromium as any)._defaultContextOptions as BrowserContextOptions;- const context = await (browser as any)._newContextForReuse(defaultContextOptions);+ const context = await (browser as BrowserImpl)._newContextForReuse(defaultContextOptions);await use(context);const closeReason = testInfo.status === 'timedOut' ? 'Test timeout of ' + testInfo.timeout + 'ms exceeded.' : 'Test ended.';- await (browser as any)._disconnectFromReusedContext(closeReason);+ await (browser as BrowserImpl)._disconnectFromReusedContext(closeReason);},page: async ({ context, _reuseContext }, use) => {@@ -471,7 +473,7 @@ function normalizeScreenshotMode(screenshot: ScreenshotOption): ScreenshotMode {}function attachConnectedHeaderIfNeeded(testInfo: TestInfo, browser: Browser | null) {- const connectHeaders: { name: string, value: string }[] | undefined = (browser as any)?._connection.headers;+ const connectHeaders: { name: string, value: string }[] | undefined = (browser as BrowserImpl | null)?._connection.headers;if (!connectHeaders)return;for (const header of connectHeaders) {