refactor: pull side effect out of action bundle import #115
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.
This PR switches our mocking library from testdouble + testdouble-vitest to vitest-when.
Testdouble is excellent, but we have to jump through some hoops to get it to work nicely with vitest. Switching to vitest-when gives us a very similar stubbing API without the overhead of opting-out of vitest's automocking / mock functions.
To make this change possible, I needed to remove a wart from the action code: prior to this PR, importing the action bundle ran the action. This side-effect on import was difficult to test, and the fact that our tests worked at all for this behavior was more brittle than I realized.
Now, the action bundle exports a
main
function, and there's a simpleaction.js
at the top-level of the repository that imports and calls that function. This is symmetrical with how the CLI works, with a simple wrapper calledbin/npm-publish.js
that imports and executes the CLI code from the compiledlib
directory.