Skip to content

test: cli.ts and action index.ts entry points have no test coverage #78

Description

@aryamthecodebreaker

Summary

The two files users actually execute have no test file:

File Role Test file
packages/cli/src/cli.ts the fixmap binary — arg parsing, exit codes, output routing none
packages/action/src/index.ts the Action entry point — inputs, step summary, outputs, comment gating none

Existing coverage is packages/cli/test/{mcp,repository-source}.test.ts and packages/action/test/github.test.ts — the libraries behind both entry points, but never the entry points themselves. apps/web has no test script at all.

Why this is worth fixing

Several defects filed alongside this one live exactly in the untested files, and each is the kind a single assertion would have caught:

  • fixmap plan --version reports "Unknown or incomplete option(s)"
  • --format yaml reports --format and yaml as unknown options
  • the Action inherits GITHUB_TOKEN / GITHUB_STEP_SUMMARY / GITHUB_OUTPUT from the ambient environment with no assertion on what it writes

Both files are also awkward to test as written, which is likely why they are not: cli.ts runs top-level statements and calls process.exit() inline, and index.ts is entirely top-level side effects. That shape is the underlying problem — the coverage gap is a symptom.

Suggested fix

  1. Extract the testable core from each entry point:
    • cli.ts -> export parseArgs(argv) and a run(options): Promise<{ stdout, stderr, exitCode }>; keep only process.exit(await run(...)) at the top level. parseArgs is a pure function and covers the whole flag matrix cheaply.
    • index.ts -> export runAction(env, deps) taking the environment and an injected GitHub client; the module top level just calls it.
  2. Add table-driven tests for the flag matrix: --version / -h in each position, --format valid + invalid, --issue=/--issue inline vs separated values, missing task signal, unknown options, --output writing to a file.
  3. Add Action tests that point GITHUB_STEP_SUMMARY and GITHUB_OUTPUT at temp files and assert the exact bytes written — particularly that the report<<delimiter heredoc is well-formed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedMaintainer welcomes community implementation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions