Skip to content

Commit d7658ca

Browse files
marco-ippolitotargos
authored andcommitted
doc: improve subtests documentation
PR-URL: #51379 Fixes: #51359 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
1 parent 17593d9 commit d7658ca

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

doc/api/test.md

+11-4
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,12 @@ If any tests fail, the process exit code is set to `1`.
105105

106106
## Subtests
107107

108-
The test context's `test()` method allows subtests to be created. This method
109-
behaves identically to the top level `test()` function. The following example
110-
demonstrates the creation of a top level test with two subtests.
108+
The test context's `test()` method allows subtests to be created.
109+
It allows you to structure your tests in a hierarchical manner,
110+
where you can create nested tests within a larger test.
111+
This method behaves identically to the top level `test()` function.
112+
The following example demonstrates the creation of a
113+
top level test with two subtests.
111114

112115
```js
113116
test('top level test', async (t) => {
@@ -121,9 +124,13 @@ test('top level test', async (t) => {
121124
});
122125
```
123126

127+
> **Note:** `beforeEach` and `afterEach` hooks are triggered
128+
> between each subtest execution.
129+
124130
In this example, `await` is used to ensure that both subtests have completed.
125131
This is necessary because parent tests do not wait for their subtests to
126-
complete. Any subtests that are still outstanding when their parent finishes
132+
complete, unlike tests created with the `describe` and `it` syntax.
133+
Any subtests that are still outstanding when their parent finishes
127134
are cancelled and treated as failures. Any subtest failures cause the parent
128135
test to fail.
129136

0 commit comments

Comments
 (0)