Skip to content
pubscout

google_sign_in_mocks

0.4.2, released 2 months ago by wafrat.com

Mocks for Google Sign In to write unit tests for authentication.

WASM-ready
$ flutter pub add google_sign_in_mocks
Source repository

What it does

Provides a mock implementation of Google Sign In for unit testing Dart and Flutter applications. It enables simulating successful sign-ins, user cancellations, and exceptions without requiring actual platform integrations.

AI-written summary of version 0.4.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are writing unit tests that involve Google Sign In.
  • You want to test authentication flows and cancellation states locally.

Skip it when

  • You are building production authentication features in your application.

Strengths

  • Easy to set up and use in unit tests alongside firebase_auth_mocks.
  • Allows simulation of canceled sign-ins and custom exceptions.

Weaknesses

  • Limited only to mocking Google Sign In functionality for testing.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
2

Not documented

import 'package:google_sign_in_mocks/google_sign_in_mocks.dart';
import 'package:test/test.dart';

void main() {
  late MockGoogleSignIn googleSignIn;
  setUp(() {
    googleSignIn = MockGoogleSignIn();
  });

  test('should return idToken when authenticating', () async {
    final signInAccount = await googleSignIn.signIn();
    final signInAuthentication = await signInAccount!.authentication;
    expect(signInAuthentication, isNotNull);
  });
}

Alternatives

Packages that do the same job and could replace google_sign_in_mocks.

Works with

Packages commonly used together with google_sign_in_mocks: ones it builds on, ones built on it, and its own family.