Skip to content

Feat/107 improve test coverage - #137

Open
vignesh2731 wants to merge 3 commits into
mainfrom
feat/107-improve-test-coverage
Open

Feat/107 improve test coverage#137
vignesh2731 wants to merge 3 commits into
mainfrom
feat/107-improve-test-coverage

Conversation

@vignesh2731

@vignesh2731 vignesh2731 commented Jul 3, 2026

Copy link
Copy Markdown

Closes #107.

Makes vet-action easy to test by mocking the GitHub Actions environment and GitHub APIs behind reusable helpers, then expands coverage of the current flows.

Changes

  • __tests__/helpers/ — reusable mocks (createTestVet, stubGitHubActionsEnv, createMockOctokit, stubVetBinaryLifecycle, …) and response/event fixtures.
  • Testsrun() routing, push flow, full PR pipeline (happy + policy-violation), comment proxy fallback, cloud config, version resolution; new utils/rpc tests; real input parsing in main.
  • docs/testing.md — guide to the common mocks.
  • Consolidated tests under __tests__/ and fixed the coverage include glob in vitest.config.ts (was reporting 0%).

Results

  • Tests: 15 → 65
  • Coverage: 42% → ~85% (vet.ts 33%→82%, rpc.ts/utils.ts → 100%)

Notes

  • src/vet.ts loads @actions/exec/tool-cache/artifact via require(), which vi.mock can't intercept — tests stub the wrapping methods (documented in docs/testing.md). ESM-import conversion + a DI refactor to drop the @ts-expect-error private access are good follow-ups.

npm run ci-test, coverage, lint, format:check all green.

vignesh2731 and others added 2 commits June 30, 2026 12:51
Introduce reusable test infrastructure for mocking the GitHub Actions
environment, GitHub APIs (Octokit), and the vet binary lifecycle so
business-logic tests avoid duplicated setup:

- __tests__/helpers/mocks.ts: stubGitHubActionsEnv, createMockOctokit,
  createTestVet, stubVetBinaryLifecycle, createMockCoreSummary,
  stubPullRequestContext, createMockCommentsProxyClient
- __tests__/helpers/fixtures.ts: factories for GitHub API responses and
  event payloads

Expand coverage of current flows (15 -> 65 tests, ~85% of src):
- vet.test.ts: run() routing, runOnPush, full runOnPullRequest pipeline
  (happy + policy-violation), comment proxy fallback, cloud config,
  policy/version resolution, PR helpers
- utils.test.ts, rpc.test.ts: new
- main.test.ts: real input parsing -> Vet config wiring + error handling

Also:
- Consolidate all tests under __tests__/ (move vet.test.ts out of src/)
- Fix coverage include glob in vitest.config.ts (was reporting 0%)
- Add docs/testing.md guide for common GitHub Actions mocks

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The coverage section still described the old './src/**' include glob; update
it to match vitest.config.ts (src/**/*.ts, test files excluded).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vignesh2731
vignesh2731 requested a review from abhisek as a code owner July 3, 2026 10:09
@safedep

safedep Bot commented Jul 3, 2026

Copy link
Copy Markdown

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

View complete scan results →

This report is generated by SafeDep Github App

Add a language to the layout code fence (MD040) and convert the helper
reference table to a bulleted list so no line exceeds 80 chars (MD013);
Prettier aligns markdown tables past that limit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

Improve Test Coverage of vet-action

1 participant