fix: properly handle negated timed-out toPass matcher (#19580)

This commit is contained in:
Andrey Lushnikov 2022-12-20 08:41:32 -08:00 committed by GitHub
parent bb2a2c7331
commit d7e7cab44a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -358,5 +358,5 @@ export async function toPass(
`- ${timeoutMessage}`,
].join('\n') : timeoutMessage;
return { message, pass: false };
return { message, pass: isNot ? true : false };
}

View File

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