Skip to content

Commit 8ae5aea

Browse files
fix kotlin tests / add js tests
1 parent 9eb02af commit 8ae5aea

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

packages/core/RNSentryAndroidTester/app/src/test/java/io/sentry/react/RNSentryModuleImplTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class RNSentryModuleImplTest {
233233
val options = SentryAndroidOptions()
234234
val rnOptions = JavaOnlyMap.of()
235235
module.trySetIgnoreErrors(options, rnOptions)
236-
assertEquals(emptyList<String>(), options.ignoredErrors)
236+
assertNull(options.ignoredErrors)
237237
}
238238

239239
@Test
@@ -267,7 +267,7 @@ class RNSentryModuleImplTest {
267267
.of(special),
268268
)
269269
module.trySetIgnoreErrors(options, rnOptions)
270-
assertEquals(listOf(".*Error*WithStar.*"), options.ignoredErrors)
270+
assertEquals(listOf(".*\\QError*WithStar\\E.*"), options.ignoredErrors!!.map { it.filterString })
271271

272272
val regex = Regex(options.ignoredErrors!![0].filterString)
273273
assertTrue(regex.matches("Error*WithStar"))

packages/core/test/wrapper.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,37 @@ describe('Tests Native Wrapper', () => {
281281
expect(RNSentry.setContext).not.toBeCalled();
282282
expect(RNSentry.setExtra).not.toBeCalled();
283283
});
284+
285+
test('sets ignoreErrorsStr and ignoreErrorsRegex correctly when ignoreErrors contains strings and regex', async () => {
286+
const regex1 = /foo/;
287+
const regex2 = new RegExp('bar');
288+
await NATIVE.initNativeSdk({
289+
dsn: 'test',
290+
enableNative: true,
291+
ignoreErrors: ['string1', regex1, 'string2', regex2],
292+
devServerUrl: undefined,
293+
defaultSidecarUrl: undefined,
294+
mobileReplayOptions: undefined,
295+
});
296+
expect(RNSentry.initNativeSdk).toBeCalled();
297+
const initParameter = (RNSentry.initNativeSdk as jest.MockedFunction<any>).mock.calls[0][0];
298+
expect(initParameter.ignoreErrorsStr).toEqual(['string1', 'string2']);
299+
expect(initParameter.ignoreErrorsRegex).toEqual([regex1.source, regex2.source]);
300+
});
301+
302+
test('does not set ignoreErrorsStr or ignoreErrorsRegex if ignoreErrors is not provided', async () => {
303+
await NATIVE.initNativeSdk({
304+
dsn: 'test',
305+
enableNative: true,
306+
devServerUrl: undefined,
307+
defaultSidecarUrl: undefined,
308+
mobileReplayOptions: undefined,
309+
});
310+
expect(RNSentry.initNativeSdk).toBeCalled();
311+
const initParameter = (RNSentry.initNativeSdk as jest.MockedFunction<any>).mock.calls[0][0];
312+
expect(initParameter.ignoreErrorsStr).toBeUndefined();
313+
expect(initParameter.ignoreErrorsRegex).toBeUndefined();
314+
});
284315
});
285316

286317
describe('sendEnvelope', () => {

0 commit comments

Comments
 (0)