Skip to content

Commit 252dec7

Browse files
committed
chore: run flaky tests
1 parent a783cea commit 252dec7

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@ jobs:
3030
- name: Build
3131
run: pnpm run build
3232

33+
- name: Flaky
34+
run: pnpm run test:flaky
35+
3336
- name: Test
3437
run: pnpm run test:ci

test/flaky/fixtures/math.spec.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { describe, test } from 'vitest'
2+
3+
test('should add numbers correctly', { retry: 5 }, ({ expect, task }) => {
4+
expect(task.result?.retryCount).toBe(0)
5+
})
6+
7+
test('should subtract numbers correctly', { retry: 5 }, ({ expect, task }) => {
8+
expect(task.result?.retryCount).toBe(1)
9+
})
10+
11+
test('should multiply numbers correctly', { retry: 5 }, ({ expect, task }) => {
12+
expect(task.result?.retryCount).toBe(5)
13+
})
14+
15+
test('should divide numbers correctly', { retry: 5 }, ({ expect, task }) => {
16+
expect(task.result?.retryCount).toBe(2)
17+
})
18+
19+
test('should handle edge cases', { retry: 5 }, ({ expect, task }) => {
20+
expect(task.result?.retryCount).toBe(4)
21+
})
22+
23+
test('should validate input properly', { retry: 5 }, ({ expect, task }) => {
24+
expect(task.result?.retryCount).toBe(4)
25+
})
26+
27+
describe('special math', () => {
28+
test.todo('should compute percentages')
29+
30+
test.skip('should divide by zero', ({ expect }) => {
31+
expect.unreachable()
32+
})
33+
34+
test.fails('should work with linear equations', ({ expect }) => {
35+
expect(true).toBe(false)
36+
})
37+
38+
test('should compute square root of negative numbers', ({ expect }) => {
39+
expect.unreachable()
40+
})
41+
})
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { describe, test } from 'vitest'
2+
3+
describe('network', () => {
4+
test('should fetch user data from API', { retry: 3 }, ({ expect, task }) => {
5+
expect(task.result?.retryCount).toBe(2)
6+
})
7+
8+
test('should handle network timeouts gracefully', { retry: 4 }, ({ expect, task }) => {
9+
expect(task.result?.retryCount).toBe(4)
10+
})
11+
12+
test('should retry failed requests', { retry: 3 }, ({ expect, task }) => {
13+
expect(task.result?.retryCount).toBe(1)
14+
})
15+
})

0 commit comments

Comments
 (0)