fix(flutter/test): tolerate Riverpod 3's ProviderException wrapper

This commit is contained in:
2026-05-08 14:43:31 -04:00
parent da1cb7b590
commit 1ad67dbe59
@@ -14,7 +14,19 @@ void main() {
test('audioHandlerProvider must be overridden — bare read throws', () {
final container = ProviderContainer();
addTearDown(container.dispose);
expect(() => container.read(audioHandlerProvider), throwsA(isA<UnimplementedError>()));
// Riverpod 3 wraps the underlying error in a ProviderException. The
// intent of the test is "bare read fails," so accept the wrapper as
// long as the inner error is the UnimplementedError we threw.
expect(
() => container.read(audioHandlerProvider),
throwsA(predicate((e) {
if (e is UnimplementedError) return true;
// ProviderException is private to riverpod; match by name + by
// walking its toString for the inner UnimplementedError text.
return e.runtimeType.toString().contains('ProviderException') &&
e.toString().contains('UnimplementedError');
})),
);
});
test('overridden audioHandlerProvider exposes playbackState stream', () {