-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Add a level
parameter to test runner diagnostics
#55922
Comments
Hi @RedYetiDev @MoLow, I would love to contribute to this. |
Feel free to open a PR |
Hi @RedYetiDev, Here is the Summary of Planned changes, please take a look and give feedback Summary of Planned ChangesTo address the problem of coverage threshold errors not being visually distinct, I propose the following enhancements:
|
Hey @hpatel292-seneca, thanks for contributing! 😊 Only one thing: atm, the message is a string parameter. Just a trivial reminder: please ensure tests are added to cover this feature. |
Understood. Thanks @pmarchini |
Hi @pmarchini, I just wanted to confirm one thing, diagnostic(nesting, loc, message, level = 'info') {
this[kEmitMessage]('test:diagnostic', {
__proto__: null,
nesting,
message,
level,
...loc,
});
} Then I updated #handleEvent({ type, data }) {
switch (type) {
case 'test:fail':
if (data.details?.error?.failureType !== kSubtestsFailed) {
ArrayPrototypePush(this.#failedTests, data);
}
return this.#handleTestReportEvent(type, data);
case 'test:pass':
return this.#handleTestReportEvent(type, data);
case 'test:start':
ArrayPrototypeUnshift(this.#stack, { __proto__: null, data, type });
break;
case 'test:stderr':
case 'test:stdout':
return data.message;
case 'test:diagnostic': // Here I added logic
const diagnosticColor =
reporterColorMap[data.level] || reporterColorMap['test:diagnostic'];
return `${diagnosticColor}${indent(data.nesting)}${
reporterUnicodeSymbolMap[type]
}${data.message}${colors.white}\n`;
case 'test:coverage':
return getCoverageReport(
indent(data.nesting),
data.summary,
reporterUnicodeSymbolMap['test:coverage'],
colors.blue,
true
);
}
} And I am Updated const reporterColorMap = {
__proto__: null,
get 'test:fail'() {
return colors.red;
},
get 'test:pass'() {
return colors.green;
},
get 'test:diagnostic'() {
return colors.blue;
},
get info() {
return colors.blue;
},
get debug() {
return colors.gray;
},
get warn() {
return colors.yellow;
},
get error() {
return colors.red;
},
}; and color already contain logic for this colors so my question is I will set the reporter.diagnostic call from test.js like this (level="Error") if (actual < threshold) {
harness.success = false;
process.exitCode = kGenericUserError;
reporter.diagnostic(
nesting,
loc,
`Error: ${NumberPrototypeToFixed(
actual,
2
)}% ${name} coverage does not meet threshold of ${threshold}%.`,
'error' // Level is set to error for red color
);
} right? |
Hey @hpatel292-seneca, I would suggest moving this discussion to a draft PR! Also, please include at least some tests (even in the draft) to verify the behavior 🚀 |
Hi @pmarchini, I am confused, I read Building.md but not sure what option is best for me to build Node. I have windows. Could you please let me know what is best option to build Node locally for Windows. Thanks |
I would suggest going with option 3: Boxstarter 🚀 |
maybe we should add a
level
parameter in diagnostics (i.e debug/info/warn/error) so reporters can implement coloring or other thingsOriginally posted by @MoLow in #55911 (comment)
The text was updated successfully, but these errors were encountered: