Skip to content

Commit

Permalink
Fix flaky exception identifier test on web (#2201)
Browse files Browse the repository at this point in the history
* Fix test
  • Loading branch information
buenaflor authored Jul 30, 2024
1 parent c19bfb6 commit 6a5a65d
Showing 1 changed file with 44 additions and 33 deletions.
77 changes: 44 additions & 33 deletions flutter/test/sentry_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -666,39 +666,50 @@ void main() {
await expectLater(SentryFlutter.pauseAppHangTracking(), completes);
});

test(
'should add DartExceptionTypeIdentifier and FlutterExceptionTypeIdentifier by default',
() async {
SentryOptions? actualOptions;
await SentryFlutter.init(
(options) {
options.dsn = fakeDsn;
options.automatedTestMode = true;
actualOptions = options;
},
appRunner: appRunner,
);

expect(actualOptions!.exceptionTypeIdentifiers.length, 2);
// Flutter identifier should be first as it's more specific
expect(
actualOptions!.exceptionTypeIdentifiers.first,
isA<CachingExceptionTypeIdentifier>().having(
(c) => c.identifier,
'wrapped identifier',
isA<FlutterExceptionTypeIdentifier>(),
),
);
expect(
actualOptions!.exceptionTypeIdentifiers[1],
isA<CachingExceptionTypeIdentifier>().having(
(c) => c.identifier,
'wrapped identifier',
isA<DartExceptionTypeIdentifier>(),
),
);

await Sentry.close();
group('exception identifiers', () {
setUp(() async {
loadTestPackage();
await Sentry.close();
});

test(
'should add DartExceptionTypeIdentifier and FlutterExceptionTypeIdentifier by default',
() async {
SentryOptions? actualOptions;
await SentryFlutter.init(
(options) {
options.dsn = fakeDsn;
options.automatedTestMode = true;
actualOptions = options;
},
appRunner: appRunner,
platformChecker: getPlatformChecker(
platform: MockPlatform.android(),
isWeb: true,
),
);

expect(actualOptions!.exceptionTypeIdentifiers.length, 2);
// Flutter identifier should be first as it's more specific
expect(
actualOptions!.exceptionTypeIdentifiers.first,
isA<CachingExceptionTypeIdentifier>().having(
(c) => c.identifier,
'wrapped identifier',
isA<FlutterExceptionTypeIdentifier>(),
),
);
expect(
actualOptions!.exceptionTypeIdentifiers[1],
isA<CachingExceptionTypeIdentifier>().having(
(c) => c.identifier,
'wrapped identifier',
isA<DartExceptionTypeIdentifier>(),
),
);

await Sentry.close();
});
});
}

Expand Down

0 comments on commit 6a5a65d

Please sign in to comment.