Skip to content

Commit

Permalink
fix: properly handle negated timed-out toPass matcher (#19580)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslushnikov committed Dec 20, 2022
1 parent bb2a2c7 commit d7e7cab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/playwright-test/src/matchers/matchers.ts
Expand Up @@ -358,5 +358,5 @@ export async function toPass(
`- ${timeoutMessage}`,
].join('\n') : timeoutMessage;

return { message, pass: false };
return { message, pass: isNot ? true : false };
}
15 changes: 14 additions & 1 deletion tests/playwright-test/expect-to-pass.spec.ts
Expand Up @@ -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);
});
});

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);
});

0 comments on commit d7e7cab

Please sign in to comment.