From fc6a93d24e9c046bdc7d08c5db30d26c0ac44326 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Tue, 19 Oct 2021 09:13:16 -0700 Subject: [PATCH] test: expect.not.toBeChecked when no elements match (#9607) --- .../playwright.expect.true.spec.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/playwright-test/playwright.expect.true.spec.ts b/tests/playwright-test/playwright.expect.true.spec.ts index 2539776148..c94d469635 100644 --- a/tests/playwright-test/playwright.expect.true.spec.ts +++ b/tests/playwright-test/playwright.expect.true.spec.ts @@ -58,14 +58,25 @@ test('should support toBeChecked w/ not', async ({ runInlineTest }) => { const locator = page.locator('input'); await expect(locator).not.toBeChecked({ timeout: 1000 }); }); + + test('fail missing', async ({ page }) => { + await page.setContent('
no inputs here
'); + const locator2 = page.locator('input2'); + await expect(locator2).not.toBeChecked({ timeout: 1000 }); + }); `, }, { workers: 1 }); const output = stripAscii(result.output); + expect(result.passed).toBe(1); + expect(result.failed).toBe(2); + expect(result.exitCode).toBe(1); + // fail not expect(output).toContain('Error: expect(received).not.toBeChecked()'); expect(output).toContain('expect(locator).not.toBeChecked'); - expect(result.passed).toBe(1); - expect(result.failed).toBe(1); - expect(result.exitCode).toBe(1); + expect(output).toContain('selector resolved to '); + // fail missing + expect(output).toContain('expect(locator2).not.toBeChecked'); + expect(output).toContain('waiting for selector "input2"'); }); test('should support toBeEditable, toBeEnabled, toBeDisabled, toBeEmpty', async ({ runInlineTest }) => {