Skip to content

test_runner: add level-based diagnostic handling for reporter #57923

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

JacopoPatroclo
Copy link

@JacopoPatroclo JacopoPatroclo commented Apr 18, 2025

The aim is to pick the work done by @hpatel292-seneca here #55964 fixing a small issue on a test.

hpatel292-seneca and others added 12 commits April 18, 2025 15:03
Added a parameter to allow severity-based formatting for
diagnostic messages. Defaults to 'info'.
This update enables better control over message presentation
(e.g., coloring) based on severity levels such as 'info', 'warn',
and 'error'.

Refs: nodejs#55922
Updated to process the parameter for events. Messages
are now formatted with colors based on the
(e.g., 'info', 'warn', 'error').
This change ensures diagnostic messages are visually distinct,
improving clarity and reducing debugging effort during test runs.

Refs: nodejs#55922
Enhanced  to include colors for the following
diagnostic levels:
 : blue - info
 : yellow - warn
 : red - error

Refs: nodejs#55922
Updated coverage threshold checks in to use the
parameter when calling. Errors now use the
'error' level for red-colored formatting.
This ensures coverage errors are highlighted effectively in the output.

Fixes: nodejs#55922
implemented requested change by removing debug
from reporterColorMap

Refs: nodejs#55964 (review)
updated the documentation for the 'test:diagnostic' event to
include the new level parameter. clarified its purpose, default
value, and possible severity levels ('info', 'warn',
'error').

Fixes: nodejs#55922
Add a test in  to verify that
the diagnostic error messages about unmet coverage thresholds
are displayed in red when using the spec reporter.

Fixes: nodejs#55922
Added eslint-disable comment to bypass no-control-regex.
This allows testing ANSI escape sequences for red color
in error messages without triggering lint errors.

Fixes: nodejs#55922
Updated the description of the  parameter to note
that color output is specific to the spec reporter. This
helps users understand its behavior and create custom
reporters with accurate expectations.

Fixes: nodejs#55922
add a test to ensure that diagnostic events emitted by the test
runner contain level parameter.

Refs: nodejs#55964
Added eslint-disable-next-line to
bypass no-unused-vars check

ref: nodejs#55964
Co-authored-by: Harshil Patel <26harshilpatel11@gmail.com>
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Apr 18, 2025
@hpatel292-seneca
Copy link

Hi @JacopoPatroclo, Thanks for working on it. I was bit busy with a new role.

Copy link

codecov bot commented Apr 18, 2025

Codecov Report

Attention: Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 90.26%. Comparing base (6cdcaa9) to head (d009a9d).
Report is 83 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/test_runner/reporter/utils.js 77.77% 2 Missing ⚠️
lib/internal/test_runner/test.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57923      +/-   ##
==========================================
- Coverage   90.26%   90.26%   -0.01%     
==========================================
  Files         630      630              
  Lines      185933   185945      +12     
  Branches    36447    36452       +5     
==========================================
+ Hits       167840   167849       +9     
- Misses      10971    10978       +7     
+ Partials     7122     7118       -4     
Files with missing lines Coverage Δ
lib/internal/test_runner/reporter/spec.js 96.63% <100.00%> (+0.05%) ⬆️
lib/internal/test_runner/tests_stream.js 90.00% <100.00%> (+0.05%) ⬆️
lib/internal/test_runner/test.js 97.14% <0.00%> (ø)
lib/internal/test_runner/reporter/utils.js 93.13% <77.77%> (-1.49%) ⬇️

... and 23 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pmarchini pmarchini requested review from cjihrig and MoLow April 26, 2025 16:20
@pmarchini pmarchini added the request-ci Add this label to start a Jenkins CI on a PR. label May 1, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 1, 2025
@nodejs-github-bot
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants