Skip to content

test: Add CLI integration test for version output #86

Closed

Description

@admarble

Problem

The getCurrentVersion() bug (returning 0.0.0) passed all unit tests because they mocked fs. We only caught it after releasing v1.5.4 and testing manually.

Solution

Add an integration test that runs the actual built CLI and verifies real output.

// src/commands/cli.integration.test.ts
import { execSync } from 'child_process';

describe('CLI integration', () => {
  it('reports correct version', () => {
    const output = execSync('node dist/bin/cli.js --version').toString();
    const pkg = require('../../package.json');
    expect(output.trim()).toBe(pkg.version);
  });

  it('status shows matching package version', () => {
    const output = execSync('node dist/bin/cli.js status').toString();
    const pkg = require('../../package.json');
    expect(output).toContain(`Package version: ${pkg.version}`);
  });
});

Why Not Unit Tests?

Unit tests mock dependencies, so they can't catch:

  • Path resolution bugs (like the ../.. vs ../../.. issue)
  • Build output issues
  • Package.json location issues

Integration tests run the real artifact.

Acceptance Criteria

  • Integration test runs built CLI (dist/bin/cli.js)
  • Verifies --version matches package.json
  • Verifies status command shows correct package version
  • Test runs as part of npm test (after build)
  • Test skipped if dist/ doesn't exist (for fresh clones)

Discovered From

Session where v1.5.4 was released with 0.0.0 bug, requiring immediate v1.5.5 fix.

Activity

  1. added
    enhancement
    on Jan 14, 2026
  2. added a commit that references this issue on Jan 16, 2026
  3. admarble commented on Jan 16, 2026

    @admarble
    ContributorAuthor

    /exec Progress Update

    AC Coverage

    AC Description Status
    AC-1 Integration test runs built CLI (dist/bin/cli.js) ✅ MET
    AC-2 Verifies --version matches package.json ✅ MET
    AC-3 Verifies status command shows correct package version ✅ MET
    AC-4 Test runs as part of npm test ✅ MET
    AC-5 Test skipped if dist/ doesn't exist ✅ MET

    Files Changed

    • src/commands/cli.integration.test.ts (new, 129 lines)

    Test Results

    • Tests: 366 passed, 1 skipped
    • Build: Success

    Self-Evaluation

    • Worked as expected: Yes
    • Test coverage confidence: High - directly tests the bug scenario from v1.5.4
    • Weakest part: describe.skipIf block is slightly redundant since beforeAll builds anyway
    • Honest assessment: Implementation is solid and guards against the regression

    PR: #101


    Ready for review.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions