Since error reporting is usually enabled in staging/production environments, users may not write tests for it. And to be honest, there isn't a clear way to test it either (probably only verifying the arguments are sent to Sentry.capture_exception correctly?).
As both a user and a maintainer of the SDK, I sometimes hope there are helpers to verify event payloads when developing apps. Ideally, it'll be something like:
# in addition to inject test helpers, it'll also
# - enable the SDK in a test-only mode (haven't decided what that means yet)
# - replace HTTPTransport with DummyTransport
include Sentry::TestHelper
it "reports the exception to Sentry" do
expect do
do_something
end.to have_sent_event_to_sentry(transaction: "PostsController#create", exception: "ZeroDivisionError")
# or for a more detailed verification
# captured_sentry_events is defined in Sentry::TestHelper
last_event = captured_sentry_events.last
expect(last_event.contexts).to match(....)
end
Since error reporting is usually enabled in staging/production environments, users may not write tests for it. And to be honest, there isn't a clear way to test it either (probably only verifying the arguments are sent to
Sentry.capture_exceptioncorrectly?).As both a user and a maintainer of the SDK, I sometimes hope there are helpers to verify event payloads when developing apps. Ideally, it'll be something like: