From b2742976a85795ed0cadad4e85c8e7fd475dd7dc Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Thu, 8 Jul 2021 09:36:28 -0700 Subject: [PATCH] fix(runner): do not restart worker after skipping tests (#7511) --- src/test/workerRunner.ts | 2 +- tests/playwright-test/worker-index.spec.ts | 46 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/test/workerRunner.ts b/src/test/workerRunner.ts index 566dfac71f..d8ea34ee10 100644 --- a/src/test/workerRunner.ts +++ b/src/test/workerRunner.ts @@ -338,7 +338,7 @@ export class WorkerRunner extends EventEmitter { if (!preserveOutput) await removeFolderAsync(testInfo.outputDir).catch(e => {}); - if (testInfo.status !== 'passed') { + if (testInfo.status !== 'passed' && testInfo.status !== 'skipped') { this._failedTestId = testId; this._reportDoneAndStop(); } diff --git a/tests/playwright-test/worker-index.spec.ts b/tests/playwright-test/worker-index.spec.ts index b2afac1df6..9b89b7a6b1 100644 --- a/tests/playwright-test/worker-index.spec.ts +++ b/tests/playwright-test/worker-index.spec.ts @@ -69,6 +69,52 @@ test('should reuse worker for multiple tests', async ({ runInlineTest }) => { expect(result.exitCode).toBe(0); }); +test('should reuse worker after test.fixme()', async ({ runInlineTest }) => { + const result = await runInlineTest({ + 'a.test.js': ` + const { test } = pwt; + test('succeeds 1', async ({}, testInfo) => { + expect(testInfo.workerIndex).toBe(0); + }); + + test('fixme 1', async ({}, testInfo) => { + test.fixme(); + expect(testInfo.workerIndex).toBe(0); + }); + + test('succeeds 2', async ({}, testInfo) => { + expect(testInfo.workerIndex).toBe(0); + }); + `, + }); + expect(result.passed).toBe(2); + expect(result.skipped).toBe(1); + expect(result.exitCode).toBe(0); +}); + +test('should reuse worker after test.skip()', async ({ runInlineTest }) => { + const result = await runInlineTest({ + 'a.test.js': ` + const { test } = pwt; + test('succeeds 1', async ({}, testInfo) => { + expect(testInfo.workerIndex).toBe(0); + }); + + test('skip 1', async ({}, testInfo) => { + test.skip(); + expect(testInfo.workerIndex).toBe(0); + }); + + test('succeeds 2', async ({}, testInfo) => { + expect(testInfo.workerIndex).toBe(0); + }); + `, + }); + expect(result.passed).toBe(2); + expect(result.skipped).toBe(1); + expect(result.exitCode).toBe(0); +}); + test('should not reuse worker for different suites', async ({ runInlineTest }) => { const result = await runInlineTest({ 'playwright.config.ts': `