-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test visibility] Early Flake Detection for vitest (#4714)
- Loading branch information
1 parent
2a8c61d
commit 3582894
Showing
4 changed files
with
745 additions
and
16 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
integration-tests/ci-visibility/vitest-tests/early-flake-detection.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { describe, test, expect } from 'vitest' | ||
import { sum } from './sum' | ||
|
||
let numAttempt = 0 | ||
let numOtherAttempt = 0 | ||
|
||
describe('early flake detection', () => { | ||
test('can retry tests that eventually pass', { repeats: process.env.SHOULD_REPEAT && 2 }, () => { | ||
expect(sum(1, 2)).to.equal(numAttempt++ > 1 ? 3 : 4) | ||
}) | ||
|
||
test('can retry tests that always pass', { repeats: process.env.SHOULD_REPEAT && 2 }, () => { | ||
if (process.env.ALWAYS_FAIL) { | ||
expect(sum(1, 2)).to.equal(4) | ||
} else { | ||
expect(sum(1, 2)).to.equal(3) | ||
} | ||
}) | ||
|
||
test('does not retry if it is not new', () => { | ||
expect(sum(1, 2)).to.equal(3) | ||
}) | ||
|
||
test.skip('does not retry if the test is skipped', () => { | ||
expect(sum(1, 2)).to.equal(3) | ||
}) | ||
|
||
if (process.env.SHOULD_ADD_EVENTUALLY_FAIL) { | ||
test('can retry tests that eventually fail', () => { | ||
expect(sum(1, 2)).to.equal(numOtherAttempt++ < 3 ? 3 : 4) | ||
}) | ||
} | ||
}) |
Oops, something went wrong.