sentry-testkit icon indicating copy to clipboard operation
sentry-testkit copied to clipboard

[Question]: Sentry Testkit and Expo

Open tigar opened this issue 2 years ago • 2 comments

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)

tigar avatar May 10 '22 18:05 tigar

@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?

zivl avatar Jun 29 '22 10:06 zivl

Stale issue message

github-actions[bot] avatar Oct 20 '22 03:10 github-actions[bot]