getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.79k stars 1.53k forks source link

Import on jest doesn't work #12782

Open sarunast opened 3 weeks ago

sarunast commented 3 weeks ago

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

8.15.0

Framework Version

Jest 29.7.0, Next 14.1.4

Link to Sentry event

No response

SDK Setup/Reproduction Example

No response

Steps to Reproduce

On client everything works as expected. If include import in jest environment it fails:

    import { createReduxEnhancer } from "@sentry/nextjs";

Everything is working fine with version 7.

Expected Result

I would like the import to still work.

Actual Result


  ● Test suite failed to run

    Cannot find module '@sentry/nextjs' from 'libs/redux/src/lib/store.ts'

    Require stack:
      libs/redux/src/lib/store.ts
      libs/authentication/src/lib/FormLogin.spec.tsx

      3 |   type StoreEnhancer,
      4 | } from "@reduxjs/toolkit";
    > 5 | import { createReduxEnhancer } from "@sentry/nextjs";
        | ^

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.<anonymous> (libs/redux/src/lib/store.ts:5:1)
      at Object.<anonymous> (libs/authentication/src/lib/FormLogin.spec.tsx:5:1)
andreiborza commented 2 weeks ago

Hi, thanks for writing in. I couldn't reproduce this locally. Do you have a sample reproduction repo?