You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an**Object**is provided, it allows specifying both a failure reason and validation logic simultaneously.
44
+
### 3. Explicit Configuration Object
45
+
To provide**both**a reason and validation, use an object with `message` and `with` properties.
37
46
38
47
```js
39
48
test('fails with reason and specific error', {
@@ -46,15 +55,14 @@ test('fails with reason and specific error', {
46
55
});
47
56
```
48
57
-**Properties**:
49
-
-`message` (String): The failure reason/label (displayed in reporter).
50
-
-`with` (RegExp | Object | Function | Class): Validation logic. This is passed directly to `assert.throws` validation argument, supporting all its capabilities.
51
-
-**Behavior**: The test passes **only if** the error matches the `with` criteria.
52
-
-**Output**: The reporter displays the `message`.
58
+
-`message` (String): The failure reason/label.
59
+
-`with` (Any): Validation logic passed to `assert.throws`.
53
60
54
61
## Ambiguity Resolution
55
-
Potential ambiguity is resolved by strict type separation:
62
+
Potential ambiguity is resolved by checking the type and structure:
56
63
*`typeof value === 'string'` → **Reason**
57
-
*`typeof value === 'object'` → **Configuration Object** (`message` and/or `with`)
0 commit comments