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
docs: update expectFailure proposal with validation details
Update the `expectFailure` enhancements proposal based on feedback and implementation alignment:
- Consolidate validation logic under the `with` property within an object.
- Remove direct RegExp support in favor of the object syntax for consistency.
- Specify usage of `assert.throws` for robust error validation.
- Document alternatives considered (flat options).
-**Behavior**: The test passes **only if** the error matches the `match` criteria.
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.
55
52
-**Output**: The reporter displays the `message`.
56
53
57
54
## Ambiguity Resolution
58
55
Potential ambiguity is resolved by strict type separation:
59
56
*`typeof value === 'string'` → **Reason**
60
-
*`value instanceof RegExp` → **Matcher**
61
-
*`typeof value === 'object'` → **Both** (Explicit properties)
57
+
*`typeof value === 'object'` → **Configuration Object** (`message` and/or `with`)
58
+
59
+
## Alternatives Considered
60
+
61
+
### Flat Options (`expectFailureError`)
62
+
It was proposed to split the options into `expectFailure` (reason) and `expectFailureError` (validation).
63
+
```js
64
+
{
65
+
expectFailure:'reason',
66
+
expectFailureError:/error/
67
+
}
68
+
```
69
+
This was rejected in favor of the nested object structure to:
70
+
1. Keep related configuration grouped.
71
+
2. Avoid polluting the top-level options namespace.
72
+
3. Allow future extensibility within the `expectFailure` object.
73
+
74
+
## Implementation Details
75
+
76
+
### Validation Logic
77
+
The implementation leverages `assert.throws` internally to perform error validation. This ensures consistency with the existing assertion ecosystem and supports advanced validation (Classes, Custom Functions) out of the box without code duplication.
0 commit comments