Skip to content

test(cli): cover formatLintFindings and normalizeErrorMessage#1208

Open
calcarazgre646 wants to merge 1 commit into
heygen-com:mainfrom
calcarazgre646:test/cli-format-helpers
Open

test(cli): cover formatLintFindings and normalizeErrorMessage#1208
calcarazgre646 wants to merge 1 commit into
heygen-com:mainfrom
calcarazgre646:test/cli-format-helpers

Conversation

@calcarazgre646
Copy link
Copy Markdown
Contributor

What

Test coverage for two pure cli helpers that had none:

  • utils/lintFormat.ts (formatLintFindings): the shared console formatter behind lint, render, preview, and publish. 12 tests covering the file-label threshold (single vs multiple files), showElementId, info suppression by default and inclusion under verbose, input-order default vs errorsFirst grouping (info last), the indented Fix: hint line, and the showSummary footer including the verbose-only info count.
  • utils/errorMessage.ts (normalizeErrorMessage): the fallback cascade used by render error paths. 10 tests covering Error instances, strings, objects with and without a string message, the JSON fallback, the key-list fallback for cyclic objects, the String() last resort for an object that throws from both JSON.stringify and Object.keys (Proxy with a throwing ownKeys trap), and the null/undefined/primitive paths.

No source changes.

Notes

  • Fixtures build the full ProjectLintResult shape (per-file counts plus totals) rather than only the fields the formatter happens to read, so they stay valid if the formatter starts consuming more of the result.
  • Output assertions target plain substrings. ui/colors.ts disables ANSI when stdout is not a TTY, which holds for vitest workers locally and in CI.
  • Each assertion group was checked against a mutated implementation before committing (disabling errorsFirst grouping and removing the message-property preference both produce failures).

Suite: 710/710 cli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant