From 81a2e0bfc0d26d814bcd97e48abaf7a2d5316bac Mon Sep 17 00:00:00 2001 From: Dmitry Sharabin Date: Tue, 23 Jun 2026 18:45:35 +0200 Subject: [PATCH] Document beforeAll/afterAll ordering in nested groups --- SKILL.md | 2 ++ docs/define/README.md | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/SKILL.md b/SKILL.md index 4bd45a4..97a1260 100644 --- a/SKILL.md +++ b/SKILL.md @@ -157,6 +157,8 @@ export default { | `beforeEach` / `afterEach` | Run before/after each test. Called like `run` — same `this`, same arguments. Inherited. Sync or async | | `beforeAll` / `afterAll` | Run before/after all tests in the group where defined. Called with no arguments. **Not inherited** | +In nested groups, `beforeAll` runs top-down (parent → child) and `afterAll` runs bottom-up (child → parent); async cleanup is awaited before the next level fires. + A child that defines its own `beforeEach`/`afterEach` **overrides** the parent's — they are not chained automatically. To invoke the parent's hook from a child override, call `this.parent.beforeEach()` (or whichever hook). You control where the parent's logic runs — before, after, or in the middle of the child's: diff --git a/docs/define/README.md b/docs/define/README.md index df7c046..96b28cc 100644 --- a/docs/define/README.md +++ b/docs/define/README.md @@ -85,6 +85,10 @@ This gives you full control over where the parent's logic runs — before your o } ``` +#### Ordering + +In nested groups, `beforeAll` runs **top-down** — the outermost group's setup runs first, then its children's. `afterAll` runs **bottom-up** — the innermost group's teardown completes (including any async work) before its parent's starts. This matches the convention in Jest, Vitest, and Mocha. + #### Error handling If a hook throws, the test is **skipped** — not failed.