Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d7658ca

Browse filesBrowse 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
Copy full SHA for d7658ca

File tree

Expand file treeCollapse file tree

1 file changed

+11
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-4
lines changed
Open diff view settings
Collapse file

‎doc/api/test.md‎

Copy file name to clipboardExpand all lines: doc/api/test.md
+11-4Lines changed: 11 additions & 4 deletions
  • Display the source diff
  • Display the rich diff
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.