From 8accabdb59297e53a772c27b6f9ccb8522a19920 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Mon, 20 Mar 2023 12:52:52 -0700 Subject: [PATCH] test: gardening (#21814) Notable changes: - `page-event-crash` is not a page test, moving out of page/. - One of the expect tests is directly covered by another, merging them. --- tests/library/har.spec.ts | 2 +- .../page-event-crash.spec.ts | 0 tests/library/tracing.spec.ts | 2 +- tests/page/page-goto.spec.ts | 6 ++-- tests/playwright-test/expect.spec.ts | 29 +------------------ 5 files changed, 7 insertions(+), 32 deletions(-) rename tests/{page => library}/page-event-crash.spec.ts (100%) diff --git a/tests/library/har.spec.ts b/tests/library/har.spec.ts index 0a0e911f68..23296d2a25 100644 --- a/tests/library/har.spec.ts +++ b/tests/library/har.spec.ts @@ -661,7 +661,7 @@ it('should return security details directly from response', async ({ contextFact const response = await page.goto(httpsServer.EMPTY_PAGE); const securityDetails = await response.securityDetails(); if (browserName === 'webkit' && platform === 'win32') - expect(securityDetails).toEqual({ subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: -1 }); + expect({ ...securityDetails, protocol: undefined }).toEqual({ subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: -1 }); else if (browserName === 'webkit') expect(securityDetails).toEqual({ protocol: 'TLS 1.3', subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: 33086084863 }); else diff --git a/tests/page/page-event-crash.spec.ts b/tests/library/page-event-crash.spec.ts similarity index 100% rename from tests/page/page-event-crash.spec.ts rename to tests/library/page-event-crash.spec.ts diff --git a/tests/library/tracing.spec.ts b/tests/library/tracing.spec.ts index 1e73aac3ec..c3d44e6383 100644 --- a/tests/library/tracing.spec.ts +++ b/tests/library/tracing.spec.ts @@ -430,7 +430,7 @@ test('should work with multiple chunks', async ({ context, page, server }, testI await context.tracing.startChunk(); await page.setContent(''); await page.click('"Click"'); - page.click('"ClickNoButton"').catch(() => {}); + page.click('"ClickNoButton"', { timeout: 0 }).catch(() => {}); await context.tracing.stopChunk({ path: testInfo.outputPath('trace.zip') }); await context.tracing.startChunk(); diff --git a/tests/page/page-goto.spec.ts b/tests/page/page-goto.spec.ts index c8df12e90d..5188721562 100644 --- a/tests/page/page-goto.spec.ts +++ b/tests/page/page-goto.spec.ts @@ -419,8 +419,10 @@ it('should fail when replaced by another navigation', async ({ page, server, bro } }); -it('js redirect overrides url bar navigation ', async ({ page, server, browserName }) => { - it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/21574' }); +it('js redirect overrides url bar navigation ', async ({ page, server, browserName, trace }) => { + it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/20749' }); + it.skip(trace === 'on', 'tracing waits for snapshot that never arrives because pending navigation'); + server.setRoute('/a', (req, res) => { res.writeHead(200, { 'content-type': 'text/html' }); res.end(` diff --git a/tests/playwright-test/expect.spec.ts b/tests/playwright-test/expect.spec.ts index 34c2aec8c8..61fcdf50d2 100644 --- a/tests/playwright-test/expect.spec.ts +++ b/tests/playwright-test/expect.spec.ts @@ -106,34 +106,6 @@ test('should include custom error message with web-first assertions', async ({ r ].join('\n')); }); -test('should work with default expect prototype functions', async ({ runTSC, runInlineTest }) => { - const spec = ` - import { test, expect } from '@playwright/test'; - test('pass', async () => { - const expected = [1, 2, 3, 4, 5, 6]; - test.expect([4, 1, 6, 7, 3, 5, 2, 5, 4, 6]).toEqual( - expect.arrayContaining(expected), - ); - expect('foo').toEqual(expect.any(String)); - expect('foo').toEqual(expect.anything()); - expect('hello world').toEqual(expect.not.stringContaining('text')); - }); - `; - { - const result = await runTSC({ - 'a.spec.ts': spec, - }); - expect(result.exitCode).toBe(0); - } - { - const result = await runInlineTest({ - 'a.spec.ts': spec, - }); - expect(result.exitCode).toBe(0); - expect(result.passed).toBe(1); - } -}); - test('should work with generic matchers', async ({ runTSC }) => { const result = await runTSC({ 'a.spec.ts': ` @@ -173,6 +145,7 @@ test('should work with generic matchers', async ({ runTSC }) => { y: expect.any(Number), })); expect('abc').toEqual(expect.stringContaining('bc')); + expect('hello world').toEqual(expect.not.stringContaining('text')); expect(['Alicia', 'Roberto', 'Evelina']).toEqual( expect.arrayContaining([ expect.stringMatching(/^Alic/),