Repository navigation
Closed
getsentry/sentry-docs
#20251Labels
Description
What React Native libraries do you use?
Hermes, RN New Architecture, Expo Application Services (EAS), Expo (mobile only), Expo Web, Expo Router
Are you using sentry.io or on-premise?
sentry.io (SaS)
Are you using any other error monitoring solution alongside Sentry?
No
Other Error Monitoring Solution Name
No response
@sentry/react-native SDK Version
7.11.0 → 8.32.0 (@sentry/core 10.37.0 → 10.76.2)
How does your development environment look like?
System:
OS: macOS 26.5.2
Binaries:
Node: 22.14.0
Yarn: 1.22.22
npm: 10.9.2
IDEs:
Xcode: 26.6
npmPackages:
expo: 57.0.25
expo-router: 57.0.23
react: 19.2.3
react-native: 0.86.3
react-native-web: 0.21.2
jest: 29.7.0
jest-expo: 57.0.5
@sentry/react-native: 8.32.0 (@sentry/core 10.76.2)
Expo Workflow: bare (CNG)
Sentry.init()
Sentry.init({
dsn: "https://...@sentry.io/...",
...
});(Not relevant to the issue: it fails at import time, before Sentry.init() runs.)
Steps to Reproduce
- Expo project with
"jest": { "preset": "jest-expo" }(same with@react-native/jest-preset). - A module imports the SDK, e.g.
import { captureException } from "@sentry/react-native"; - A test imports that module without
jest.mock("@sentry/react-native"). - Run
npx jest.
Works on @sentry/react-native 7.11.0 (@sentry/core 10.37.0). Fails after upgrading to 8.32.0 (@sentry/core 10.76.2).
Expected Result
The test suite runs. Importing @sentry/react-native in a Jest test should not require extra Jest configuration, or the required configuration should be documented.
Actual Result
Cause
- JS SDK 10.58.0 added a
react-nativeexport condition that points at the ESM build: fix(core,browser,react): Addreact-nativeexport condition to resolve dual ESM/CJS bundling sentry-javascript#21362. - The React Native Jest environment sets
customExportConditions = ['require', 'react-native'], so Jest now resolves@sentry/core,@sentry/react,@sentry/browser,@sentry/browser-utils,@sentry/feedback,@sentry/replayand@sentry/replay-canvasto ESM. jest-expo/@react-native/jest-presetonly allow@sentry/react-nativethrough Babel, so the ESM is loaded untransformed.- This repo hit the same failure and fixed its own test suite in test(core): Resolve @sentry/* to CJS builds in Jest #6301 (custom test environment that drops the
react-nativecondition). That PR calls it "not a user-facing issue", but any app test that imports the SDK without mocking it fails the same way. Nothing in the docs or the 8.x changelog mentions it.
Workaround
Allow all @sentry/* packages through Babel:
// jest.config.js
const preset = require("jest-expo/jest-preset");
module.exports = {
preset: "jest-expo",
transformIgnorePatterns: preset.transformIgnorePatterns.map((p) =>
p.replace("@sentry/react-native", "@sentry"),
),
};Request
One of:
- Document the Jest setup in the React Native troubleshooting docs and the 8.x changelog.
- Ship a Jest test environment / preset from
@sentry/react-native(liketest/RNTestEnvironment.jsin test(core): Resolve @sentry/* to CJS builds in Jest #6301). - Upstream
@sentryto thetransformIgnorePatternsallowlist injest-expo.
Activity
linear-code commentedon Oct 27, 2026
RN-838
antonis commentedon Oct 27, 2026
Thank you for reporting @Yummy-sk 🙇 We will check this and iterate back.
docs(react-native): Add Jest "Unexpected token 'export'" troubleshoot…
antonis commentedon Oct 27, 2026
thanks again for reporting. We've updated the documentation with getsentry/sentry-docs#20251