Repository navigation
[Test Quality] Assert ANSI colorization in pretty stats output - #11395
Merged
Merged
Conversation
Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified, and the test coverage directly checks both ANSI formatting behavior and preservation of the underlying text.
No open issues 🎉
What changed in this PR
This PR strengthens the pretty statistics formatter test to verify that the colorize flag controls ANSI output without changing the underlying text.
Changes:
- Temporarily forces Chalk color output while restoring its original configuration afterward.
- Verifies plain output has no ANSI escapes.
- Verifies colored output has ANSI escapes and matches plain output after escape removal.
| File | Description |
|---|---|
| src/logs/stats-formatter.test.ts | Adds assertions covering plain and ANSI-colored pretty stats output, including equivalence after stripping escape sequences. |
Review effort: Lite (auto)
Contributor
Author
|
✅ Copilot review passed with no inline comments. @github-actions[bot] Add the |
lpcox
deleted the
test-quality/colorize-pretty-output-91bb9828375a9d85
branch
November 10, 2026 16:38
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.
Contract
formatStats(stats, 'pretty', colorize)insrc/logs/stats-formatter.ts(seeawf logs statsin CLAUDE.md) emits ANSI colors only whencolorizeis true, and otherwise emits plain text.Previous weakness
should work with colorize enabledonly assertedexpect(output).toBeTruthy(). Ignoring thecolorizeflag would still pass it.Change
The test now forces
chalk.level = 1(restored infinally) and asserts three things:Evidence
Commands:
npm run buildwas not needed; the test runs through ts-jest../node_modules/.bin/jest --runInBand --no-coverage --runTestsByPath src/logs/stats-formatter.test.tsResults:
const c = false ? chalk : ...(colors ignored):Expected substring: "\u001b[".eslinton the test file reports 0 errors and 1security/detect-non-literal-regexpwarning. TheRegExpis built from a constant ESC character to avoidno-control-regex.CI
The root Jest suite (
src/**) runs this file in the existing unit-test job.Limits
This is a component-level test of the formatter. It is not container or network enforcement evidence. No tests were removed.