Skip to content
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

Fix flaky exception identifier test on web #2201

Merged
merged 7 commits into from
Jul 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading