Skip to content

Commit d680a50

Browse files
[test optimization] Fix playwright's quarantine and retry logic (#7024)
1 parent 89ed9a5 commit d680a50

File tree

5 files changed

+348
-26
lines changed

5 files changed

+348
-26
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict'
2+
3+
const { test, expect } = require('@playwright/test')
4+
5+
test.beforeEach(async ({ page }) => {
6+
await page.goto(process.env.PW_BASE_URL)
7+
})
8+
9+
test.describe('playwright', () => {
10+
test('should not retry new tests', async ({ page }, testInfo) => {
11+
// test will always fail because ATR and --retries are disabled for EFD
12+
if (testInfo.retry === 0) {
13+
throw new Error('Hello Warld')
14+
}
15+
await expect(page.locator('.hello-world')).toHaveText([
16+
'Hello World'
17+
])
18+
})
19+
20+
test('should retry old flaky tests', async ({ page }, testInfo) => {
21+
// will eventually pass because the test is not retried by EFD
22+
if (testInfo.retry === 0) {
23+
throw new Error('Hello Warld')
24+
}
25+
await expect(page.locator('.hello-world')).toHaveText([
26+
'Hello World'
27+
])
28+
})
29+
})

integration-tests/ci-visibility/playwright-tests-test-management/attempt-to-fix-test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,11 @@ test.describe('attempt to fix', () => {
3131
expect(true).toBe(true)
3232
})
3333
})
34+
35+
if (process.env.SHOULD_INCLUDE_FLAKY_TEST) {
36+
test('flaky test is retried without attempt to fix', async ({ page }, testInfo) => {
37+
await expect(page.locator('.hello-world')).toHaveText([
38+
testInfo.retry === 0 ? 'Hello Warld' : 'Hello World'
39+
])
40+
})
41+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict'
2+
3+
const { test, expect } = require('@playwright/test')
4+
5+
test.describe('flaky', () => {
6+
test('should be flaky', async ({ page }, testInfo) => {
7+
if (testInfo.retry === 0) {
8+
throw new Error('I am flaky')
9+
}
10+
expect(true).toBe(true)
11+
})
12+
})

0 commit comments

Comments
 (0)