feat(contracts): print only contract errors and warnings - #38
Merged
Merged
Conversation
Passing mocks and skipped mocks are counted in the summary line instead of listed one per line. The full detail lives in run.json and index.html. Co-Authored-By: Claude Opus 5.5 <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.
Why
The contract block printed one line for every mock that matched its spec, plus two lines for every skipped mock, with no dedupe. On a real project that is hundreds of green `MOCK ✓` lines and the same `MOCK ℹ "getUser" /v1/me` repeated over and over, burying the one line that matters. Since 1.10.0 every run writes a report folder, so the terminal no longer has to carry the full record.
What changes
Output only: the return value, the exit code, `run.json`, `index.html`, `summary.md` and the deprecated `contractReportPath` markdown are untouched. The per-mock detail, skipped entries included, stays in `run.json` and `index.html`.
With `--no-report` the skipped detail is not written anywhere; the count is still printed. That is accepted rather than adding a verbose flag.
Before / after
```
TWD Contract Validation
Source: ./openapi.json ERROR
MOCK ✗ POST /v1/pets (201) — mock "createPet" — in "Cart > adds item"
→ response.id: expected integer, got string
Mocks validated: 839 | Errors: 1 | Warnings: 0 | Skipped: 12
```
Tests
`tests/contractReport.test.js`: the skipped test now asserts the list is not printed, the clean run asserts no `✓` and no `Source:`, and a new case checks that a source with only passing mocks gets no header. `npx vitest run`: 716 passed.
The CHANGELOG entry goes in the release commit, as usual.