-
Notifications
You must be signed in to change notification settings - Fork 5k
js: add node:test/reporters module #23366
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||||||||||||||||||||||||
| const colors = require("internal/util/colors"); | ||||||||||||||||||||||||||
| const { formatTestReport } = require("internal/test/reporter/utils"); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const ArrayPrototypePush = Array.prototype.push; | ||||||||||||||||||||||||||
| const MathMax = Math.max; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| async function* dot(source) { | ||||||||||||||||||||||||||
| let count = 0; | ||||||||||||||||||||||||||
| let columns = getLineLength(); | ||||||||||||||||||||||||||
| const failedTests = []; | ||||||||||||||||||||||||||
| for await (const { type, data } of source) { | ||||||||||||||||||||||||||
| if (type === "test:pass") { | ||||||||||||||||||||||||||
| yield `${colors.green}.${colors.reset}`; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| if (type === "test:fail") { | ||||||||||||||||||||||||||
| yield `${colors.red}X${colors.reset}`; | ||||||||||||||||||||||||||
| ArrayPrototypePush.$apply(failedTests, data); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| if ((type === "test:fail" || type === "test:pass") && ++count === columns) { | ||||||||||||||||||||||||||
| yield "\n"; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Getting again in case the terminal was resized. | ||||||||||||||||||||||||||
| columns = getLineLength(); | ||||||||||||||||||||||||||
| count = 0; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| yield "\n"; | ||||||||||||||||||||||||||
| if (failedTests.length > 0) { | ||||||||||||||||||||||||||
| yield `\n${colors.red}Failed tests:${colors.white}\n\n`; | ||||||||||||||||||||||||||
| for (const test of failedTests) { | ||||||||||||||||||||||||||
| yield formatTestReport("test:fail", test); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+28
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Color reset after “Failed tests:” header Header leaves terminal color as white; reset to avoid bleed. - yield `\n${colors.red}Failed tests:${colors.white}\n\n`;
+ yield `\n${colors.red}Failed tests:${colors.reset}\n\n`;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| function getLineLength() { | ||||||||||||||||||||||||||
| return MathMax(process.stdout.columns ?? 20, 20); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| export default dot; | ||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix undefined reference to
OriginalRegExpPrototypeExec.Line 203 references
OriginalRegExpPrototypeExec, which is not defined anywhere in this file or the visible context. This will cause aReferenceErrorat runtime.Apply this diff to use the correct variable:
exec: { __proto__: null, configurable: true, - value: OriginalRegExpPrototypeExec, + value: RegExpPrototypeExec, },📝 Committable suggestion
🤖 Prompt for AI Agents