fake_firebase_ai 0.1.0 copy "fake_firebase_ai: ^0.1.0" to clipboard
fake_firebase_ai: ^0.1.0 copied to clipboard

Fake for Firebase AI Logic (firebase_ai). Unit test Gemini calls, streaming, chat and function calling without network or API keys.

example/fake_firebase_ai_example.dart

import 'package:fake_firebase_ai/fake_firebase_ai.dart';
import 'package:firebase_ai/firebase_ai.dart';
import 'package:flutter_test/flutter_test.dart';

/// The code under test: takes a model, so tests can pass a fake one.
Future<String> summarize(GenerativeModel model, String article) async {
  final response = await model.generateContent([
    Content.text('Summarize in one line:\n$article'),
  ]);
  return response.text ?? '';
}

void main() {
  test('summarize sends the article and returns the reply', () async {
    final ai = FakeFirebaseAI()..reply('Cats are great.');
    final model = await ai.generativeModel('gemini-2.5-flash');

    expect(
      await summarize(model, 'A long article about cats.'),
      'Cats are great.',
    );
    expect(ai.requests.single.text, contains('about cats'));
  });
}
0
likes
160
points
105
downloads

Documentation

API reference

Publisher

verified publisherseungpyo.online

Weekly Downloads

Fake for Firebase AI Logic (firebase_ai). Unit test Gemini calls, streaming, chat and function calling without network or API keys.

Repository (GitHub)
View/report issues

Topics

#firebase #gemini #testing #mock #ai

License

BSD-3-Clause (license)

Dependencies

firebase_ai, firebase_core, firebase_core_platform_interface, flutter, flutter_test, http

More

Packages that depend on fake_firebase_ai