Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test(runner): new worker after test failure (#7518)

Yury Semikhatskyf5b552fde747
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': `