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(test runner types): allow sync step functions (#20996)
Dmitry Gozman55f4b670a9dc
diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.tsindex 694200a71f..8414206ff5 100644--- a/packages/playwright-test/types/test.d.ts+++ b/packages/playwright-test/types/test.d.ts@@ -3184,7 +3184,7 @@ export interface TestType<TestArgs extends KeyValue, WorkerArgs extends KeyValue* @param title Step name.* @param body Step body.*/- step<T>(title: string, body: () => Promise<T>): Promise<T>;+ step<T>(title: string, body: () => T | Promise<T>): Promise<T>;/*** `expect` function can be used to create test assertions. Read more about [test assertions](https://playwright.dev/docs/test-assertions).*diff --git a/tests/playwright-test/types-2.spec.ts b/tests/playwright-test/types-2.spec.tsindex faaee8ec89..25fa0f1e0c 100644--- a/tests/playwright-test/types-2.spec.ts+++ b/tests/playwright-test/types-2.spec.ts@@ -160,6 +160,7 @@ test('step should inherit return type from its callback ', async ({ runTSC }) =>return 'foo';});await test.step('my step', async () => { });+ const good2: string = await test.step('my step', () => 'foo');});`});diff --git a/utils/generate_types/overrides-test.d.ts b/utils/generate_types/overrides-test.d.tsindex 72b0ecf118..5e5eeb3b3b 100644--- a/utils/generate_types/overrides-test.d.ts+++ b/utils/generate_types/overrides-test.d.ts@@ -152,7 +152,7 @@ export interface TestType<TestArgs extends KeyValue, WorkerArgs extends KeyValuebeforeAll(inner: (args: TestArgs & WorkerArgs, testInfo: TestInfo) => Promise<any> | any): void;afterAll(inner: (args: TestArgs & WorkerArgs, testInfo: TestInfo) => Promise<any> | any): void;use(fixtures: Fixtures<{}, {}, TestArgs, WorkerArgs>): void;- step<T>(title: string, body: () => Promise<T>): Promise<T>;+ step<T>(title: string, body: () => T | Promise<T>): Promise<T>;expect: Expect;extend<T extends KeyValue, W extends KeyValue = {}>(fixtures: Fixtures<T, W, TestArgs, WorkerArgs>): TestType<TestArgs & T, WorkerArgs & W>;info(): TestInfo;