Skip to content

Rewrite action to avoid module mocking#55

Open
threeal wants to merge 1 commit into
mainfrom
avoid-module-mocking
Open

Rewrite action to avoid module mocking#55
threeal wants to merge 1 commit into
mainfrom
avoid-module-mocking

Conversation

@threeal

@threeal threeal commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Introduces SetupLefthookActionDeps interface in src/action.ts so all external dependencies (ghakit I/O, logging, tool cache, version fetching) are injected rather than imported directly.
  • Updates src/main.ts to construct and pass the real deps at the entry point.
  • Rewrites src/action.test.ts to build lightweight inline mock deps per test, removing all vi.mock calls and enabling concurrent test execution ({ concurrent: true }) with no shared global state.

Resolves #57

Use dependency injection via SetupLefthookActionDeps interface so tests
no longer need vi.mock — each test creates its own mock deps inline,
enabling concurrent test execution and eliminating shared global state.

Resolves threeal/setup-pnpm-action#286

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.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.

Rewrite functions to avoid module mocking

1 participant