@@ -105,9 +105,12 @@ If any tests fail, the process exit code is set to `1`.
105
105
106
106
## Subtests
107
107
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.
111
114
112
115
``` js
113
116
test (' top level test' , async (t ) => {
@@ -121,9 +124,13 @@ test('top level test', async (t) => {
121
124
});
122
125
```
123
126
127
+ > ** Note:** ` beforeEach ` and ` afterEach ` hooks are triggered
128
+ > between each subtest execution.
129
+
124
130
In this example, ` await ` is used to ensure that both subtests have completed.
125
131
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
127
134
are cancelled and treated as failures. Any subtest failures cause the parent
128
135
test to fail.
129
136
0 commit comments