test(common): Add unit tests for cli-colors utility#17069
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds unit tests for the CLI color utility to verify ANSI wrapping behavior and NO_COLOR opt-out semantics.
Changes:
- Introduces tests for
isColorAllowed()default and NO_COLOR-disabled behavior - Adds assertions for
clcstyle wrappers (e.g., green/bold) and NO_COLOR passthrough - Adds a dedicated test for the
yellow()extended ANSI formatter
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage Report for CI Build 13423Coverage increased (+0.01%) to 90.039%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
cli-colors.util.tshas no unit tests. This utility provides ANSI colorwrapping for NestJS CLI output (logger, REPL, injector) and respects the
NO_COLORenvironment variable standard — yet its color wrapping andenv-var logic are untested.
Issue Number: N/A
What is the new behavior?
Adds
packages/common/test/utils/cli-colors.util.spec.tscovering:isColorAllowed()returnstrueby defaultisColorAllowed()returnsfalsewhenNO_COLORis setclc.green()wraps text in ANSI green codesclc.bold()wraps text in ANSI bold codes (different close sequence)clc.*methods return raw text whenNO_COLORis setyellow()uses extended ANSI codesUses
afterEachcleanup to prevent cross-test env var contamination.Does this PR introduce a breaking change?
Other information
This change only adds test coverage and does not modify runtime behavior.