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: handle not.toPass() with expect.soft inside (#20596)
Andrey Lushnikovf45f20a8c959
diff --git a/packages/playwright-test/src/matchers/matchers.ts b/packages/playwright-test/src/matchers/matchers.tsindex 6dd5c658ba..6a579e066c 100644--- a/packages/playwright-test/src/matchers/matchers.ts+++ b/packages/playwright-test/src/matchers/matchers.ts@@ -352,5 +352,7 @@ export async function toPass(return { message, pass: this.isNot };}+ if (testStateBeforeToPassMatcher && testInfo)+ testInfo._restoreErrorState(testStateBeforeToPassMatcher);return { pass: !this.isNot, message: () => '' };}diff --git a/tests/playwright-test/expect-to-pass.spec.ts b/tests/playwright-test/expect-to-pass.spec.tsindex d5d9937e57..9096c24e39 100644--- a/tests/playwright-test/expect-to-pass.spec.ts+++ b/tests/playwright-test/expect-to-pass.spec.ts@@ -183,6 +183,24 @@ test('should swallow all soft errors inside toPass matcher, if successful', asynexpect(result.failed).toBe(1);});+test('should work with no.toPass and failing soft assertion', async ({ runInlineTest }) => {+ test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/20518' });++ const result = await runInlineTest({+ 'a.spec.ts': `+ const { test } = pwt;+ test('should work', async () => {+ await test.expect(() => {+ expect.soft(1).toBe(2);+ }).not.toPass({ timeout: 1000 });+ });+ `+ });+ expect(result.exitCode).toBe(0);+ expect(result.failed).toBe(0);+ expect(result.passed).toBe(1);+});+test('should show only soft errors on last toPass pass', async ({ runInlineTest }) => {const result = await runInlineTest({'a.spec.ts': `