-
Notifications
You must be signed in to change notification settings - Fork 639
feat: Add snap_trackError and snap_trackEvent support to snaps-jest
#3546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3546 +/- ##
==========================================
+ Coverage 98.26% 98.27% +0.01%
==========================================
Files 411 415 +4
Lines 11637 11717 +80
Branches 1814 1821 +7
==========================================
+ Hits 11435 11515 +80
Misses 202 202 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the tracing functions gonna be done separately? At the very least we should return some bogus data to not crash the Snap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how we can make these testable in a meaningful way, but yeah I can add a response mock at least if you prefer.
| * @yields Adds the error to the store. | ||
| */ | ||
| function* trackErrorImplementation(error: Error): SagaIterator { | ||
| const serialisedError = getJsonError(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come we need this? Shouldn't this mirror the client implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the client we deserialise to an Error instance before sending the errors to sentry. I think reserialising makes it easier to test, since you can use a standard object for assertions instead of having to construct an error.
This adds support to
snaps-jestfor thesnap_trackErrorandsnap_trackEventmethods. Internally in the simulation framework, tracked errors and events are stored in state, and made available to the response aserrorsandeventsproperties. This can be combined with the newtoTrackErrorandtoTrackEventmatchers to check if errors or events are tracked.I've updated the preinstalled example tests to use the new functionality, and added an RPC method for tracking events as well.