zivl / sentry-testkit

A Sentry plugin to allow Sentry report interception and further inspection of the data being sent
https://zivl.github.io/sentry-testkit/
MIT License
112 stars 26 forks source link

[Question]: Sentry Testkit and Expo #102

Closed tigar closed 2 years ago

tigar commented 2 years ago

Hi all,

While attempting to test my Sentry implementation on a React Native app, I've been struggling to capture the errors and events logged by Sentry.

My React Native app is built on top of Expo (for cross-platform distribution) and I haven't been able to find any docs out there showing support for Sentry with Expo. Expo maintains their own package to facilitate working with Sentry (https://github.com/expo/sentry-expo) and the imports look a little different.

For example the import looks like this: import * as Sentry from 'sentry-expo'

And logging an error requires a .Native postfix: Sentry.Native.captureException(error)

My test case looks something like this (Logger.error is a wrapper on Sentry.Native.captureException):

const mockError = jest.spyOn(Logger, 'error')
Logger.error(new Error('hello'))
expect(mockError).toBeCalledWith(new Error('hello'))
expect(testkit.reports().length).toBeGreaterThan(0)
zivl commented 2 years ago

@tigar can you share more context of your app? how do you initialize your Sentry Testkit instance? what is Logger here? why should Logger errors caught in Sentry? also - which version of sentry-expo do you use?

github-actions[bot] commented 2 years ago

Stale issue message