Feat/107 improve test coverage - #137
Open
vignesh2731 wants to merge 3 commits into
Open
Conversation
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>
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Closes #107.
Makes
vet-actioneasy 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.run()routing, push flow, full PR pipeline (happy + policy-violation), comment proxy fallback, cloud config, version resolution; newutils/rpctests; real input parsing inmain.docs/testing.md— guide to the common mocks.__tests__/and fixed the coverageincludeglob invitest.config.ts(was reporting 0%).Results
vet.ts33%→82%,rpc.ts/utils.ts→ 100%)Notes
src/vet.tsloads@actions/exec/tool-cache/artifactviarequire(), whichvi.mockcan't intercept — tests stub the wrapping methods (documented indocs/testing.md). ESM-import conversion + a DI refactor to drop the@ts-expect-errorprivate access are good follow-ups.npm run ci-test,coverage,lint,format:checkall green.