feat(cli): add Tests: summary line, Failed tests block, and MOCK prefix on contract lines#7
Merged
Merged
Conversation
Spec proposes a final, grep-friendly `Tests: N passed, M failed, K skipped` line, adds a `MOCK ` prefix to contract-validation lines to disambiguate them from test-result glyphs, and replaces console.time with a manual duration delta folded into the summary line. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Six TDD tasks: formatDuration helper, formatTestSummary + Failed tests block, MOCK prefix on contract lines, integration into runTests, and a manual smoke test against test-example-app. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wire formatTestSummary and formatFailedTestsBlock into the runTests orchestrator, replacing console.time/timeEnd with a startedAt timestamp and durationMs calculation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
TWD Contract Validation
23 passed · 41 failed · 3 warnings · 1 skipped Failed validations./contracts/users-3.0.json
./contracts/posts-3.1.json
./contracts/products-3.0.json
./contracts/events-3.1.json
|
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.
🏷️ Type of Change
📝 What?
twd-cli runnow prints a grep-friendlyTests: N passed, N failed, N skipped (N total) in m:ss.SSSsummary line at the end of every run, replacing the oldTotal Test Time:stopwatch output. When there are failures, aFailed tests:block listing each failing test name follows immediately. All contract-validation glyph lines (✓,✗,⚠,ℹ) are now prefixed withMOCKso they cannot be confused with test-result lines in log output.🤔 Why?
CI logs are hard to scan when pass/fail status is buried across dozens of lines. A single terminal-grep-able
Tests:line makes it trivial to extract the result from any log aggregator or CI summary. TheMOCKprefix disambiguates contract-validation output from test results, which matters when both appear in the same log stream.🧾 How?
Two new pure modules handle formatting:
src/formatDuration.js(converts milliseconds tom:ss.SSS) andsrc/testSummary.js(formatTestSummarybuilds the summary line with ANSI color on count digits only;formatFailedTestsBlockreturns the failure list ornull).src/index.jsreplacesconsole.time/timeEndwith aDate.now()delta and prints the summary as the final human-readable output (after "Browser closed.").src/contractReport.jsgets a minimal one-string-per-call change to injectMOCKbetween the indent and each glyph.🧪 Testing
• 4 new unit test files covering
formatDuration,formatTestSummary,formatFailedTestsBlock, and the MOCK prefix on all four contract line kinds (pass, fail, warning, skipped).• Integration test in
tests/runTests.test.jsasserts theTests:summary line andFailed tests:block are printed with correct counts and test names.• Full suite: 197 tests passing, 87% statement coverage.
🤖 Generated with Claude Code