Add comprehensive unit tests for error classes #23
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.
What's in this PR?
This PR adds comprehensive unit tests for the
OAuthErrorandTimeoutErrorclasses insrc/errors.ts, addressing issue #3.What was tested?
The tests cover all requirements from the issue:
✅ Constructor property assignment
✅ Error inheritance from native Error class
✅ Default message fallbacks
✅ Correct error naming (OAuthError, TimeoutError)
✅ Stack trace maintenance
✅ JSON serialization behavior
✅ Edge cases (long strings, unicode, null/undefined values)
✅ Error comparison (instance vs. value equality)
✅ Error recovery (verified no implementation in current design)
Key Findings (Please Read)
All tests pass except for the JSON serialization test. This test reveals the current behavior:
This is the current, tested behavior. If this is not the desired behavior for the library (e.g., if errors should serialize fully for logging), a fix would require implementing a toJSON() method on these classes. This could be explored in a future issue.
Notes