From f5b552fde747dfde5530b489cb91f257d37b36cd Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Thu, 8 Jul 2021 23:30:15 -0700 Subject: [PATCH] test(runner): new worker after test failure (#7518) --- tests/playwright-test/worker-index.spec.ts | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/playwright-test/worker-index.spec.ts b/tests/playwright-test/worker-index.spec.ts index 9b89b7a6b1..55df9a10b6 100644 --- a/tests/playwright-test/worker-index.spec.ts +++ b/tests/playwright-test/worker-index.spec.ts @@ -115,6 +115,51 @@ test('should reuse worker after test.skip()', async ({ runInlineTest }) => { expect(result.exitCode).toBe(0); }); +test('should use new worker after test.fail()', async ({ runInlineTest }) => { + const result = await runInlineTest({ + 'a.test.js': ` + const { test } = pwt; + test('succeeds 1', async ({}, testInfo) => { + expect(testInfo.workerIndex).toBe(0); + }); + + test('fail 1', async ({}, testInfo) => { + test.fail(); + expect(1).toBe(0); + }); + + test('succeeds 2', async ({}, testInfo) => { + expect(testInfo.workerIndex).toBe(1); + }); + `, + }); + expect(result.passed).toBe(3); + expect(result.failed).toBe(0); + expect(result.exitCode).toBe(0); +}); + +test('should use new worker after test failure', async ({ runInlineTest }) => { + const result = await runInlineTest({ + 'a.test.js': ` + const { test } = pwt; + test('succeeds 1', async ({}, testInfo) => { + expect(testInfo.workerIndex).toBe(0); + }); + + test('fail 1', async ({}, testInfo) => { + expect(1).toBe(0); + }); + + test('succeeds 2', async ({}, testInfo) => { + expect(testInfo.workerIndex).toBe(1); + }); + `, + }); + expect(result.passed).toBe(2); + expect(result.failed).toBe(1); + expect(result.exitCode).toBe(1); +}); + test('should not reuse worker for different suites', async ({ runInlineTest }) => { const result = await runInlineTest({ 'playwright.config.ts': `