Uh oh!
There was an error while loading. Please reload this page.
doc(proposal): expectFailure label and/or matcher - #10
Conversation
@Han5991 this should reference nodejs/node#61570 which goes beyond nodejs/node#61563. It may end up being the case that a fix for the latter lands before the former, since the latter is relatively trivial and simply brings --EDIT-- I'm a little confused. Your first proposal, #9, included a way to supply both a reason and an expected error as I proposed in nodejs/node#61570, but this one does not. |
Han5991
commented
Jan 29, 2026
Sorry for the confusion. PR #9 was accidentally opened from my other account, so I closed it and opened this one instead. |
vassudanagunta
commented
Jan 29, 2026
Alternative syntaxes to consider for supplying both reason and expected error: test('fails with reason and specific error',{expectFailure: 'Bug #123: Edge case behavior',expectFailureMessage: /errmsgpattern/},()=> ...);or for consistency with test('fails with reason and specific error',{expectFailure: 'Bug #123: Edge case behavior',expectFailureError: <RegExp> | <Function> | <Object> | <Error>},()=> ...);The user can supply either one of the two new options or both. |
vassudanagunta
commented
Jan 29, 2026
Consistency with |
Han5991
commented
Jan 29, 2026
Thanks for the feedback! Implementation: |
vassudanagunta
commented
Jan 29, 2026
the terseness and legibility of with+message is very nice. as i said on your PR, it gets my top vote. |
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).
JakobJingleheimer
commented
Jan 29, 2026
IIR, we had originally envisioned it('should do the thing',{expectFailure: 'chromium#1234'},()=>{…});it('should do another thing',{expectFailure: /sometelltaleneedle/},()=>{…});it('should do something else',{expectFailure: newRangeError(…)},()=>{…});Where matcher would follow the behaviour of |
0de23a6 to
abb5912CompareUh oh!
There was an error while loading. Please reload this page.
6e1e4a8 to
87802e3CompareHan5991
commented
Jan 30, 2026
I've updated the proposal to reflect the latest feedback. Ready for re-review! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Explicitly state that passing an empty object ({}) to expectFailure should throw ERR_INVALID_ARG_VALUE to prevent ambiguity and potential user error.vassudanagunta
commented
Jan 31, 2026
RE the back and forth on whether I agree with @ljharb in general, but in this specific case it will result in Also, given the specificity of the linked |
JakobJingleheimer
left a comment
There was a problem hiding this comment.
Thanks for this!
I think some whitespace is amiss (e.g. too many spaces between * and the text, too much indentation, missing blank line between heading and its content, etc).
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Update property names to match/label in description to match code examples. - Fix markdown formatting (whitespace, blank lines) as requested.
Han5991
commented
Feb 2, 2026
Thanks for the detailed review! I've updated the proposal to address your feedback |
JakobJingleheimer
left a comment
There was a problem hiding this comment.
🙌 LGTM aside from the small revert needed because of my mistaken assumption.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Revert activation logic to allow falsy values (e.g., empty string, 0) to enable the feature, maintaining consistency with skip/todo. - Add requirement: configuration object must contain at least one of 'label' or 'match'.
Han5991
commented
Feb 3, 2026
Thanks for the feedback. Changes have been applied based on your comments. |
vassudanagunta
left a comment
There was a problem hiding this comment.
Better to be consistent with assert.throws?
| ``` | ||
| - **Properties**: | ||
| - `label` (String): The failure reason/label (displayed in reporter). | ||
| - `match` (RegExp | Object | Function | Class): Validation logic. This is passed directly to `assert.throws` validation argument, supporting all its capabilities. |
There was a problem hiding this comment.
@JakobJingleheimer et. al., when writing my suggested changes to the PR, I noticed assert.throws names this field error, not match. Might it be better to be consistent?
There was a problem hiding this comment.
Ah, sure, yes :) error was one of the ideas I suggested (but without knowing it was what assert.throws uses).
pmarchini
commented
Feb 5, 2026
LGTM!!! |
expectFailure label and/or matcherJakobJingleheimer
commented
Feb 9, 2026
Discussed in #14 and approved. |
This PR adds a proposal for enhancing expectFailure to support both custom messages (for reasoning) and validation (matching errors via regex/objects), addressing the needs discussed in nodejs/node#61563.