Open ollie-nye opened 3 days ago
Hi @ollie-nye , thank you for the message, the RN SDK is not compatible with the JS v8 yet, we are working on the new major version as we speak https://github.com/getsentry/sentry-react-native/tree/v6.
If I understand it correct the following core results in the same error?
import * as Sentry from '@sentry/core';
it('does the thing', () => {
expect(Sentry.captureException).not.toHaveBeenCalled();
});
I would recommend keeping the Sentry JS dependencies on @sentry/core@7.117.0 to avoid issues. From the stack trace it seem like ../node_modules/@sentry/browser
is v7 which is correct, but then it load @sentry/core@8
instead of it specified v7 dependency. But I don't see why.
Thanks for picking this up so quick! Importing core directly (with a bit of required mocking) seems to behave as it should do, interestingly:
import * as Sentry from '@sentry/core';
jest.mock('@sentry/core', () => {
const actual = jest.requireActual('@sentry/core');
return {
...actual,
captureException: jest.fn(),
};
});
it('does the thing', () => {
expect(Sentry.captureException).not.toHaveBeenCalled();
});
Result:
PASS src/Test.test.tsx
✓ does the thing (1 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.625 s, estimated 1 s
We do have both v7 and v8 core in node_modules
, because another dependency is pure javascript so has updated to v8 already. We only have v7 as a direct dependency though, with @sentry/react-native
at 5.24.1
@ollie-nye Thanks, that sounds correct.
As when directly importing the @sentry/core
there is no clash. But when importing @sentry/react-native
it's ready for v7 JS and it gets v8 which is not compatible.
It seem like that during the tests the wrong version of the @sentry/core
package is loaded.
What version is ../node_modules/@sentry/browser
?
OS:
Platform:
SDK:
@sentry/react-native
(>= 1.0.0)react-native-sentry
(<= 0.43.2)SDK version:
@sentry/core@7.117.0
via@sentry/react-native@5.24.1
@sentry/core@8.11.0
via other internal dependenciesreact-native
version: 0.73.5Are you using Expo?
Are you using sentry.io or on-premise?
If you are using sentry.io, please post a link to your issue so we can take a look:
Local test only, hasn't made it out to the build yet
Configuration:
(
@sentry/react-native
)I have the following issue:
TypeError: core.convertIntegrationFnToClass is not a function
when using Jest to test an exception being reported correctly.Steps to reproduce:
Test looks something like this:
Jest has been set up to ignore transforms for
@sentry/react-native
, though I've also tried with@sentry/.*
with the same outcomeActual result:
Expected result:
A passing test
We're currently migrating from
sentry-expo
and this behaved under that library but this is the last bit that's stumped us until we can move to@sentry/react-native
. Thanks for any help or pointers anyone has!