Skip to content

test: make integration suites assert deterministic outcomes#5

Merged
riglar merged 2 commits into
devfrom
test/tighten-integration-assertions
Jun 12, 2026
Merged

test: make integration suites assert deterministic outcomes#5
riglar merged 2 commits into
devfrom
test/tighten-integration-assertions

Conversation

@riglar

@riglar riglar commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #3, knocking out the first deferred item: the integration suites could not fail. Nearly every CLI invocation was wrapped in try/catch with fallbacks accepting any output matching broad regexes (one alternation was literally /error/i), plus expect(true).to.be.true tautologies — a fully broken command still went green.

Since #3 the mock API boots deterministically (readiness polling, isolated DCD_CONFIG_DIR), so every scenario was probed against the live mock API and now asserts its actual outcome unconditionally:

  • Happy paths parse and assert real JSON shapes / exact output markers. Pointing the suite at a dead API now fails 61 tests instead of zero.
  • Failure paths use a runExpectingFailure helper (replacing expect.fail inside try/catch, which chai's own AssertionError could satisfy) and assert exact error messages and exit codes.
  • File-writing tests run in temp cwds and verify written JSON content — nothing pollutes the repo tree anymore.
  • Shared constants in test/integration/helpers.ts (mock URL with env override, API key, CLI path, dead-API URL on port 9 replacing the assumed-unbound localhost:9999).
  • Stale oclif-era regexes and a broken \\{ escape removed.

Net −914 lines of test code while getting strictly stronger.

Bug found by the tightening

--json-file-name ./output/results.json failed with ENOENT — writeJSONFile never created intermediate directories, masked by the old test asserting only the announcement message. Fixed in the first commit; the test now verifies the written file's content.

Also pinned two real behaviors as tests: junit report downloads succeed against the mock, and status --json reports errors in-band (exit 0, attempts: 1 on client errors).

Test plan

  • pnpm test: 122/122 passing
  • Mutation check: MOCK_API_URL=http://127.0.0.1:9 npx mocha ... → 61 failures (previously this scenario passed silently)
  • pnpm lint: 0 errors
  • pnpm build clean

🤖 Generated with Claude Code

riglar and others added 2 commits June 12, 2026 18:56
--json-file-name ./output/results.json failed with ENOENT because
writeJSONFile never created intermediate directories — masked until now
by an integration test that only asserted the announcement message.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The integration tests wrapped nearly every CLI invocation in try/catch
and accepted failures matching broad regexes (one alternation was
literally /error/i), plus tautological expect(true) assertions — a
fully broken command still passed the suite. The excuses are gone: the
mock API (Prism + auth shim) is booted deterministically by the test
runner with readiness polling and an isolated config dir.

Every scenario was probed against the live mock API and now asserts
its real outcome unconditionally:

- happy paths assert parsed JSON shapes / exact output markers; a dead
  or missing mock API now fails 61 tests instead of zero
- failure paths use a runExpectingFailure helper (replacing expect.fail
  inside try/catch, which chai's own AssertionError could satisfy) and
  assert the precise error message and exit code
- file-writing tests run in temp cwds, verify the written JSON content,
  and no longer pollute the repo working tree
- shared constants live in test/integration/helpers.ts: mock URL (env
  override), API key, CLI path, and a dead-API URL on port 9 (discard)
  replacing the assumed-unbound localhost:9999
- stale oclif-era regex alternations and a broken \\{ escape removed

Net -914 lines. Also surfaced two real behaviors: junit report
downloads succeed against the mock (now asserted), and --json-file-name
with intermediate directories was broken (fixed in the previous commit).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@riglar riglar merged commit cd37699 into dev Jun 12, 2026
2 checks passed
@riglar riglar deleted the test/tighten-integration-assertions branch June 18, 2026 20:12
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