Skip to content

Commit c0fcb14

Browse files
authored
docs(lifecycle): update lifecycle document format (#9866)
1 parent b72fc6b commit c0fcb14

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

guide/lifecycle.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ Understanding the test run lifecycle is essential for writing effective tests, d
1111

1212
A typical Vitest test run goes through these main phases:
1313

14-
1. **Initialization** - Configuration loading and project setup
15-
2. **Global Setup** - One-time setup before any tests run
16-
3. **Worker Creation** - Test workers are spawned based on the [pool](/config/pool) configuration
17-
4. **Test File Collection** - Test files are discovered and organized
18-
5. **Test Execution** - Tests run with their hooks and assertions
19-
6. **Reporting** - Results are collected and reported
20-
7. **Global Teardown** - Final cleanup after all tests complete
14+
1. **Initialization:** Configuration loading and project setup
15+
2. **Global Setup:** One-time setup before any tests run
16+
3. **Worker Creation:** Test workers are spawned based on the [pool](/config/pool) configuration
17+
4. **Test File Collection:** Test files are discovered and organized
18+
5. **Test Execution:** Tests run with their hooks and assertions
19+
6. **Reporting:** Results are collected and reported
20+
7. **Global Teardown:** Final cleanup after all tests complete
2121

2222
Phases 4–6 run once for each test file, so across your test suite they will execute multiple times and may also run in parallel across different files when you use more than [1 worker](/config/maxworkers).
2323

@@ -124,10 +124,10 @@ Test files are executed based on your configuration:
124124

125125
The execution follows this order:
126126

127-
1. **File-level code** - All code outside `describe` blocks runs immediately
128-
2. **Test collection** - `describe` blocks are processed, and tests are registered as side effects of importing the test file
129-
3. **[`aroundAll`](/api/hooks#aroundall) hooks** - Wrap around all tests in the suite (must call `runSuite()`)
130-
4. **[`beforeAll`](/api/hooks#beforeall) hooks** - Run once before any tests in the suite
127+
1. **File-level code:** All code outside `describe` blocks runs immediately
128+
2. **Test collection:** `describe` blocks are processed, and tests are registered as side effects of importing the test file
129+
3. **[`aroundAll`](/api/hooks#aroundall) hooks:** Wrap around all tests in the suite (must call `runSuite()`)
130+
4. **[`beforeAll`](/api/hooks#beforeall) hooks:** Run once before any tests in the suite
131131
5. **For each test:**
132132
- [`aroundEach`](/api/hooks#aroundeach) hooks wrap around the test (must call `runTest()`)
133133
- `beforeEach` hooks execute (in order defined, or based on [`sequence.hooks`](/config/sequence#sequence-hooks))
@@ -136,7 +136,7 @@ The execution follows this order:
136136
- [`onTestFinished`](/api/hooks#ontestfinished) callbacks run (always in reverse order)
137137
- If test failed: [`onTestFailed`](/api/hooks#ontestfailed) callbacks run
138138
- Note: if `repeats` or `retry` are set, all of these steps are executed again
139-
6. **[`afterAll`](/api/hooks#afterall) hooks** - Run once after all tests in the suite complete
139+
6. **[`afterAll`](/api/hooks#afterall) hooks:** Run once after all tests in the suite complete
140140

141141
**Example execution flow:**
142142

@@ -347,7 +347,7 @@ Understanding where code executes is crucial for avoiding common pitfalls:
347347

348348
In watch mode, the lifecycle repeats with some differences:
349349

350-
1. **Initial run** - Full lifecycle as described above
350+
1. **Initial run:** Full lifecycle as described above
351351
2. **On file change:**
352352
- New [test run](/api/advanced/reporters#ontestrunstart) starts
353353
- Only affected test files are re-run

0 commit comments

Comments
 (0)