Skip to content

Commit 438c44e

Browse files
authored
feat(api): add getSeed method (#8592)
1 parent bd5a6ae commit 438c44e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

docs/advanced/api/vitest.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,14 @@ function disableCoverage(): void
579579

580580
This method disables coverage collection for tests that run afterwards.
581581

582+
## getSeed <Version>4.0.0</Version> {#getseed}
583+
584+
```ts
585+
function getSeed(): number | null
586+
```
587+
588+
Returns the seed, if tests are running in a random order.
589+
582590
## experimental_parseSpecification <Version>4.0.0</Version> <Badge type="warning">experimental</Badge> {#parsespecification}
583591

584592
```ts

packages/vitest/src/node/core.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,13 @@ export class Vitest {
502502
}
503503
}
504504

505+
/**
506+
* Returns the seed, if tests are running in a random order.
507+
*/
508+
public getSeed(): number | null {
509+
return this.config.sequence.seed ?? null
510+
}
511+
505512
/** @internal */
506513
public async _reportFileTask(file: File): Promise<void> {
507514
const project = this.getProjectByName(file.projectName || '')

0 commit comments

Comments
 (0)