Repository navigation
feat(experimental): seed repeats and add --replay-seed - #11940
sheremet-va wants to merge 1 commit into
Conversation
✅ Deploy Preview for vitest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
de9e773 to
82d056c
Compare
7307e86 to
e4df218
Compare
e4df218 to
3bf6b08
Compare
| ### repeats | ||
|
|
||
| - **Type:** `number` | ||
| - **Type:** `number | { count?: number; include?: string[] }` |
There was a problem hiding this comment.
repeats.include feels like weird API to control the used seeds. Maybe it should contain the word seed at least. Right now it looks like test.include. 🤷
There was a problem hiding this comment.
Agree, and there is also value in rerunning the same seed multiple times. Maybe we need a new option:
new seed
repeat x10
retry x2
There was a problem hiding this comment.
Changed to seeds:
import { test } from 'vitest'
test('one leader per term', { repeats: 199, seeds: ['3fa2c9e1b07d5a44'] }, async ({ random }) => {
// ...
})"repeats" still try different seeds each time
There was a problem hiding this comment.
Also working on examples to use instead of seeds which is more useful in a controlled environment:
import { test } from 'vitest'
test('the queue keeps every job', {
repeats: 99,
examples: [{ jobs: [501] }],
}, ({ random }) => {
const jobs = random.many('jobs', () => random.int(0, 1000))
// ...
})There was a problem hiding this comment.
Could you add test case where we have test('...', { repeats: { include: ['0123456789abcdef'] }..., and defineConfig({ test: { repeats: 10 } }) or pass --repeats 10 via CLI. Does the test case now run twice, 10 or 11 times?
There was a problem hiding this comment.
I'll add it, but it should run 12 times right now. repeats makes it so the test runs repeats + 1 time (the initial run + repeats) always, and include adds an additional repeat
There was a problem hiding this comment.
11 or 12 sounds correct to me. By looking at the code I wasn't sure if defining inline repeats here in test() would accidentally override the --repeats=10 / test.repeats: 10 from root too.
3bf6b08 to
f35705f
Compare
1c1ee7a to
3bbe4ff
Compare
3db5564 to
2e0d33d
Compare
2e0d33d to
553a5d3
Compare
553a5d3 to
b8590c8
Compare
b8590c8 to
987ad51
Compare
987ad51 to
db37ec4
Compare
Stacked on #11933. Contains the commit of #11955 until it merges.
Each repeat of a test gets its own seed for
context.randomandvi.useFakeRandom, sorepeatssearches for the values that make a test fail. When a repeat fails, Vitest runs its seed 1 more time to check that the failure reproduces, and prints the seed with a command that replays it.--replay-seed <seed>runs the selected tests 1 time with this seed.seedstest option runs known seeds before the repeats. Each seed adds 1 run, so therepeatsof a tag or of--repeatsstill apply.retryIndexandrepeatIndexof their attempt.--seedof the run and drops--reporter,--outputFile,--ui,--open,--api,--coverageand--update.