-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
test_runner: simplify logic, nix dead reporter code #59700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
reporter/utils.js formatTestReport:
1. hasChildren and showErrorDetails are never both true in
existing calls.
2. Thus if hasChildren is true, showErrorDetails is false.
3. So `|| data.details?.error?.failureType === 'subtestsFailed'`
is irrelevant.
4. And `\n${error}` never occurs.
Even though all tests pass after this commit, what if future reporter
code might make calls where both hasChildren and showErrorDetails
are true? I will address this in the last commit of this PR.
Trust me for now.
1. formatTestReport: inline the `const error` 2. move the check for `data.details?.error` out of formatError to its sole caller, formatTestReport, which makes more sense. 3. collapse the nested ternary expressions in formatTestReport to one.
reporter/utils.js formatTestReport: 1. consider again that hasChildren and showErrorDetails are never both true in existing calls to formatTestReport.
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #59700 +/- ##
==========================================
- Coverage 89.93% 89.92% -0.02%
==========================================
Files 667 667
Lines 196792 196767 -25
Branches 38426 38405 -21
==========================================
- Hits 176983 176939 -44
- Misses 12233 12242 +9
- Partials 7576 7586 +10
🚀 New features to boost your workflow:
|
1. formatTestReport: hasChildren arg is unused
2. consider that the existing calls to formatTestReport break down into
two types:
- print a line in the test result tree without error details (spec)
- print error details (spec and dot)
i.e. whether or not to showErrorDetails.
e9085b9 to
44ccad8
Compare
|
@MoLow @pmarchini could one of you review this soonish, before conflicts get introduced by other commits? It's both simple and simplifying, but i spent a bit of time on it, including having to set up node builds on my machine. The affected lines were introduced by a number of various people fixing a number of issues; so dead/unnecessary stuff accumulated. |
While trying to understand the underlying logic of the built-in test reporters, necessary because documentation of the semantics of TestsStream is minimal, I was thoroughly confused by this code in
formatTestReport:...and not just because of the obfuscation. It made sense that if
data.details?.error?.failureType === 'subtestsFailed', the error should not be reported against the parent test, and even that this condition is only tested ifhasChildrenis true. But all callers that do pass inhasChildren(which otherwise defaults to false) also pass inshowErrorDetails: false, so that part of the convoluted nested ternary never even fires.Ok, I thought, maybe
formatTestReportrepresents an API the current built-in reporters do not use fully. But that seems a little odd because it is internal. So I reduced it to its essence, as currently used. I did it in four steps because I'm old and need to break things down more than you young'uns might need. Each step is a commit, with explanation in the commit message, with each commit passing all tests.The upshot is the above gets reduced to
along with an easier to understand formatTestReport function signature and removal of more dead code in the spec reporter.