dart-lang / mockito

Mockito-inspired mock library for Dart
https://pub.dev/packages/mockito
Apache License 2.0
636 stars 163 forks source link

Bad state: Asset URI is missing for abstract class JSObject #762

Open Rexios80 opened 4 months ago

Rexios80 commented 4 months ago
Bad state: Asset URI is missing for abstract class JSObject
package:mockito/src/builder.dart 2200:10                     _MockClassInfo._typeImport
package:mockito/src/builder.dart 1676:21                     _MockClassInfo._addFakeClass.<fn>.<fn>.<fn>
package:code_builder/src/specs/type_reference.g.dart 164:33  _$TypeReferenceBuilder.update
package:code_builder/src/specs/type_reference.g.dart 22:36   new _$TypeReference
package:mockito/src/builder.dart 1673:33                     _MockClassInfo._addFakeClass.<fn>.<fn>
package:mockito/src/builder.dart 2075:24                     _MockClassInfo._withTypeParameters
package:mockito/src/builder.dart 1670:7                      _MockClassInfo._addFakeClass.<fn>
package:code_builder/src/specs/class.g.dart 345:33           _$ClassBuilder.update
package:code_builder/src/specs/class.g.dart 40:28            new _$Class
package:mockito/src/builder.dart 1663:37                     _MockClassInfo._addFakeClass
package:mockito/src/builder.dart 1622:7                      _MockClassInfo._dummyFakedValue
package:mockito/src/builder.dart 1644:27                     _MockClassInfo._dummyValueImplementing
package:mockito/src/builder.dart 1549:12                     _MockClassInfo._dummyValue
package:mockito/src/builder.dart 1652:11                     _MockClassInfo._dummyValueImplementing
package:mockito/src/builder.dart 1549:12                     _MockClassInfo._dummyValue
package:mockito/src/builder.dart 1951:24                     _MockClassInfo._buildOverridingGetter
package:mockito/src/builder.dart 1224:36                     _MockClassInfo.fieldOverrides.<fn>
package:code_builder/src/specs/method.g.dart 323:33          _$MethodBuilder.update
package:code_builder/src/specs/method.g.dart 38:29           new _$Method
package:mockito/src/builder.dart 1224:15                     _MockClassInfo.fieldOverrides
dart:core                                                    List.addAll
package:built_collection/src/list/list_builder.dart 98:14    ListBuilder.addAll
package:mockito/src/builder.dart 1182:28                     _MockClassInfo._buildMockClass.<fn>.<fn>
package:mockito/src/builder.dart 2075:24                     _MockClassInfo._withTypeParameters
package:mockito/src/builder.dart 1136:7                      _MockClassInfo._buildMockClass.<fn>
package:code_builder/src/specs/class.g.dart 345:33           _$ClassBuilder.update
package:code_builder/src/specs/class.g.dart 40:28            new _$Class
package:mockito/src/builder.dart 1114:12                     _MockClassInfo._buildMockClass
package:mockito/src/builder.dart 1060:9                      new _MockLibraryInfo
package:mockito/src/builder.dart 94:29                       MockBuilder.build

I get this when attempting to generate these mocks: https://github.com/Rexios80/packages_flutter/blob/afb21bc501403de977c404c995cbc41502381d9b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart#L24

I had this issue before switching to the latest commit of mockito (which should really be released by now): https://github.com/dart-lang/mockito/issues/732

This is the type that's causing the issue:

abstract class GeometryController {
  /// The GMap instance that this controller operates on.
  late gmaps.Map googleMap;
}

@JS('google.maps.Map')
extension type Map._(MVCObject _) implements MVCObject {}

I tried adding googleMap to the unsupportedMembers but it doesn't make a difference

Rexios80 commented 4 months ago

Okay I swear I tried adding something to fallbackGenerators to fix this before but I did it just now and it works

srawlins commented 4 months ago

Mockito still shouldn't crash so we'll leave this open.