-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to get mock metadata: node_modules/@sentry/react/cjs/index.js #5994
Comments
The issue started happening after I upgraded |
Node.js version: 18.11.0 |
Thanks for writing in! I ran into this here when running We did make some refactors around using global objects, perhaps that had some effect. #5948 Perhaps we have to change our entry points as was discussed in aws-amplify/amplify-js#4499? @SimenB perhaps you have some context on what could be going on here? |
@AbhiPrasad I just wanted to report that I'm having the same issue. I haven't had a chance to dig into the links you shared and probably won't until the weekend, but this does seem to be an issue going from |
The temp fix here for everyone is to actually add mocks for your method, similar to what is done here: https://github.com/getsentry/sentry-javascript/pull/5951/files#diff-9b6a20828c3c1c7a7e897abb6d7c8a88130fc3ac55dad3cbd8d3ac92aff19fadR9 Probably also cleaner because you can control exactly what is being mocked, but that’s probably a matter of opinion on coding style. |
@EvgenyOrekhov @jackmccloy - Two questions: Does either of you have |
@lobsterkatie I don't have |
I have the same issue. Suggestions don't work for me neither. |
I'm getting the same issue but for mocking EDIT: Confirmed that jest unit tests work in EDIT2: Confirmed working in 7.15.0 - the release that broke this is 7.16.0 |
Can confirm the same issue with:
I do not have This browser test fails:
This node one fails:
|
This seems to be a jest bug - will be fixed by jestjs/jest#13513 |
…'` to CJS files (#6043) As of version 2.69.0, setting `output.generatedCode` to `'es2015'` (as we do) causes Rollup to [add `[Symbol.toStringTag]: 'Module'` to generated CJS files](rollup/rollup#4378 (comment)). Though this is valid ES6, it causes Jest to be unable to mock our generated packages. Though [a PR](jestjs/jest#13513) has been opened to fix this, the change almost certainly won't be backported, so anyone using Jest 29.2.2 or under will run into [this problem](#5994) if they try to mock `@sentry/xxx` 7.16. (The relevant change was introduced in #5951, when we (semi-)accidentally upgraded Rollup from 2.67.1 to 2.78.0, and was first included in version 7.16.) This PR prevents the new Rollup behavior, since it has no known benefit. (The [Rollup docs](https://rollupjs.org/guide/en/#outputgeneratedcode) say that presence of the `'Module'` toStringTag "is used for feature detection in certain libraries and frameworks," but not having it hasn't seemed to hurt us so far.)
This will be fixed in the SDK with the next release - we recognize that not everyone can bump jest versions, but do want to shout out @Tofandel for fixing this in jest directly! Appreciate the patience everyone! |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
@sentry/react
SDK Version
7.16.0
Framework Version
React 18.2.0
Link to Sentry event
No response
Steps to Reproduce
Expected Result
No error
Actual Result
Test fails with
Failed to get mock metadata: node_modules/@sentry/react/cjs/index.js
The text was updated successfully, but these errors were encountered: