From b110b4758dfec3600cf77ddcecb0489aa0c7edaf Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Tue, 12 Nov 2024 17:07:55 -0800 Subject: [PATCH] Support sync steps --- packages/playwright/src/common/testType.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/playwright/src/common/testType.ts b/packages/playwright/src/common/testType.ts index afdbe5f448..d3c2f1c23a 100644 --- a/packages/playwright/src/common/testType.ts +++ b/packages/playwright/src/common/testType.ts @@ -257,14 +257,14 @@ export class TestTypeImpl { suite._use.push({ fixtures, location }); } - async _step(title: string, body: () => Promise, options: {box?: boolean, location?: Location, timeout?: number } = {}): Promise { + async _step(title: string, body: () => T | Promise, options: {box?: boolean, location?: Location, timeout?: number } = {}): Promise { const testInfo = currentTestInfo(); if (!testInfo) throw new Error(`test.step() can only be called from a test`); const step = testInfo._addStep({ category: 'test.step', title, location: options.location, box: options.box }); return await zones.run('stepZone', step, async () => { try { - const result = await raceAgainstDeadline(body, options.timeout ? monotonicTime() + options.timeout : 0); + const result = await raceAgainstDeadline(async () => body(), options.timeout ? monotonicTime() + options.timeout : 0); if (result.timedOut) throw new errors.TimeoutError(`Step timeout ${options.timeout}ms exceeded.`); step.complete({});