Fix spy leak and unsafe error cast from PR #32 review#33
Merged
Conversation
Wrap copyFileSync spy restore in finally block so the mock cannot leak when the assertion throws. Use defensive type checks in the catch block to avoid throwing on non-Error objects.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
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.
Summary
Address review feedback from #32 (identified by cubic).
Changes
token-extractor.test.ts— WrapcopyFileSyncSpy.mockRestore()in afinallyblock so the globalfsmock cannot leak when the assertion throws.ensure-auth.ts— Use defensive type checks (typeof error === 'object',instanceof Error) in the catch block instead of bare casts, preventing a secondary throw on non-Error objects.Summary by cubic
Fixes a leaking fs spy in tests and hardens ensureSlackAuth error handling to avoid secondary crashes. Improves test isolation and prevents noisy failures when non-Error values are thrown.
Written for commit 5ab1bbe. Summary will update on new commits.