From 6a5a65d1390ef72425d385815fbfb4c1b03ced8d Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Tue, 30 Jul 2024 15:30:40 +0200 Subject: [PATCH] Fix flaky exception identifier test on web (#2201) * Fix test --- flutter/test/sentry_flutter_test.dart | 77 +++++++++++++++------------ 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/flutter/test/sentry_flutter_test.dart b/flutter/test/sentry_flutter_test.dart index c05bf7b7cf..1d78b947d1 100644 --- a/flutter/test/sentry_flutter_test.dart +++ b/flutter/test/sentry_flutter_test.dart @@ -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().having( - (c) => c.identifier, - 'wrapped identifier', - isA(), - ), - ); - expect( - actualOptions!.exceptionTypeIdentifiers[1], - isA().having( - (c) => c.identifier, - 'wrapped identifier', - isA(), - ), - ); - - 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().having( + (c) => c.identifier, + 'wrapped identifier', + isA(), + ), + ); + expect( + actualOptions!.exceptionTypeIdentifiers[1], + isA().having( + (c) => c.identifier, + 'wrapped identifier', + isA(), + ), + ); + + await Sentry.close(); + }); }); }