test_runner: support custom message for expectFailure#61563
test_runner: support custom message for expectFailure#61563Han5991 wants to merge 1 commit intonodejs:mainfrom
Conversation
|
Review requested:
|
@JakobJingleheimer In that case, I'd be happy to pivot this PR to implement the expectFailure validation logic (accepting a string/regex to match the error) instead of just a message. Does that sound good, or is there someone else already working on it?" |
|
@vassudanagunta you were part of the original discussion; did you happen to start an implementation? To my knowledge though, no-one has started. I had planned to pick it up next week, but if you would like to do, go ahead. If you do, I think it would probably be better to start a new PR than to pivot this one. So open a draft and I'll add it to the test-runner team's kanban board so it gets proper visibility. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61563 +/- ##
=======================================
Coverage 89.74% 89.74%
=======================================
Files 675 675
Lines 204735 204808 +73
Branches 39348 39369 +21
=======================================
+ Hits 183737 183815 +78
- Misses 13269 13271 +2
+ Partials 7729 7722 -7
🚀 New features to boost your workflow:
|
|
@JakobJingleheimer nope, haven't started this, though I had long ago implemented it in I think it's important to get the requirements nailed. IMHO, #61570. |
|
As I said, let's put together a proposal in the nodejs/test_runner repo 🙂 |
This comment was marked as resolved.
This comment was marked as resolved.
|
reviewed before reading the discussion; imo a string should work as in this PR whether or not it also supports accepting a regex. |
|
It could do. My concern is supporting this without considering the intended regex feature accidentally precluding that intended feature, or inadvertently creating a breaking change, or creating heavily conflicting PRs (very frustrating for the implementators). I think we can likely get both; we can easily avoid those problems with a quick proposal so everyone is on the same page 🙂
Please start a proposal like the ones already in that repo 🙂 https://github.com/nodejs/test-runner/tree/main/proposals we can discuss it in that PR |
|
conflicts fair; as long as the "should expect failure" uses truthiness (does an empty string count as true or false, though?), i can't foresee any semantic collision. |
1af3584 to
13aedaa
Compare
|
I've opened a proposal PR in the test-runner repository as suggested by @JakobJingleheimer. |
061f049 to
346ec8f
Compare
vassudanagunta
left a comment
There was a problem hiding this comment.
I think this needs to be documented a little better for the user.
|
@Han5991 the proposal isn't finished / accepted yet (still hasn't been reviewed by the rest of the test-runner team), so I think it's premature to resume this (the proposal isn't a requirement, but I think it's a good idea and will reduce churn, needless re-reviews, etc—and indeed, there was just earlier today another adjustment to align terms). I do appreciate the enthusiasm 😁 It's added to the team's agenda, so it'll get raised at the next meeting. |
|
Thanks for letting me know. I'll leave it as a draft until the proposal is finalized. |
|
@Han5991 the proposal is all set, so full-steam ahead 🙂 (or whatever pace you want) |
7946173 to
48e85f0
Compare
48e85f0 to
a5eaf98
Compare
|
@JakobJingleheimer |
c2bebdf to
7145647
Compare
This comment was marked as resolved.
This comment was marked as resolved.
vassudanagunta
left a comment
There was a problem hiding this comment.
Some new examples do not jive with the explanatory text. Can reduce the number of examples and shorten the doc without losing any explanatory power.
09def7f to
8fa0720
Compare
vassudanagunta
left a comment
There was a problem hiding this comment.
Looks like suite-level support for expectFailure was missed the first time around. Should fix this now... I think it will be easy.
891ad18 to
01cf2c4
Compare
01cf2c4 to
b453aca
Compare
Normalize expectFailure values to support string labels, direct
matchers, and { label, match } objects while validating errors via
assert.throws.
Allow tests to inherit the 'expectFailure' option from their parent
suite.
Update TAP reporting and tests, including function matcher coverage
and unexpected-pass behavior, and clarify docs for direct matcher
usage.
Resolves: nodejs#61570
b453aca to
80928f7
Compare
|
The PR is ready. Please review it! |
|
We still have the question about whether |
Summary
This PR enhances the
expectFailureoption in the test runner to accept different types of values, enabling both custom failure labels and robust error validation. This implementation is referenced from and inspired by nodejs/test-runner#10.Changes
The
expectFailureoption now supports the following types:String: Treated as a failure label (reason).
RegExp / Function / Error Class: Treated as a matcher to validate the thrown error (similar to
assert.throws).Object:
labelormatchproperties, it's treated as a configuration object.Inheritance:
expectFailurefrom their parent suite. This allows marking an entire suite as expected to fail.References
expectFailurelabel and/or matcher test-runner#10Resolves: #61570