Skip to content

Jest fails with "Unexpected token 'export'" in @sentry/core since the react-native export condition (JS SDK 10.58.0) #6953

Closed
getsentry/sentry-docs
#20251

Description

@Yummy-sk

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

  1. Expo project with "jest": { "preset": "jest-expo" } (same with @react-native/jest-preset).
  2. A module imports the SDK, e.g. import { captureException } from "@sentry/react-native";
  3. A test imports that module without jest.mock("@sentry/react-native").
  4. 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-native export condition that points at the ESM build: fix(core,browser,react): Add react-native export 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/replay and @sentry/replay-canvas to ESM.
  • jest-expo / @react-native/jest-preset only allow @sentry/react-native through 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-native condition). 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 (like test/RNTestEnvironment.js in test(core): Resolve @sentry/* to CJS builds in Jest #6301).
  • Upstream @sentry to the transformIgnorePatterns allowlist in jest-expo.

Activity

  1. linear-code commented on Oct 27, 2026

    @linear-code
  2. self-assigned this
    on Oct 27, 2026
  3. antonis commented on Oct 27, 2026

    @antonis
    Contributor

    Thank you for reporting @Yummy-sk 🙇 We will check this and iterate back.

  4. added a commit that references this issue on Oct 27, 2026
    6519f70
  5. antonis commented on Oct 27, 2026

    @antonis
    Contributor

    thanks again for reporting. We've updated the documentation with getsentry/sentry-docs#20251

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions