diff --git a/packages/playwright-test/src/matchers/matchers.ts b/packages/playwright-test/src/matchers/matchers.ts index 3d39c390fb0da..b9477377e340c 100644 --- a/packages/playwright-test/src/matchers/matchers.ts +++ b/packages/playwright-test/src/matchers/matchers.ts @@ -358,5 +358,5 @@ export async function toPass( `- ${timeoutMessage}`, ].join('\n') : timeoutMessage; - return { message, pass: false }; + return { message, pass: isNot ? true : false }; } diff --git a/tests/playwright-test/expect-to-pass.spec.ts b/tests/playwright-test/expect-to-pass.spec.ts index d76cf094c1f61..82f630843805e 100644 --- a/tests/playwright-test/expect-to-pass.spec.ts +++ b/tests/playwright-test/expect-to-pass.spec.ts @@ -166,4 +166,17 @@ test('should work with soft', async ({ runInlineTest }) => { expect(stripAnsi(result.output)).toContain('Received: 2'); expect(result.exitCode).toBe(1); expect(result.failed).toBe(1); -}); \ No newline at end of file +}); + +test('should not accept TimeoutError', async ({ runInlineTest }) => { + const result = await runInlineTest({ + 'a.spec.ts': ` + const { test } = pwt; + test('should fail', async () => { + await test.expect(() => {}).not.toPass({ timeout: 1 }); + }); + ` + }); + expect(result.exitCode).toBe(1); + expect(result.failed).toBe(1); +});