test library
Testing utilities for the AI SDK Dart.
Import this library in your tests to get access to mock/fake model
implementations that mirror the JS AI SDK v6 ai/test sub-path.
import 'package:ai_sdk_dart/test.dart';
final model = MockLanguageModelV4(
response: [MockTextPart('Hello, world!')],
);
Classes
-
MockEmbeddingModelV2<
VALUE> - A controllable mock embedding model for testing.
-
MockEmbeddingModelV3<
VALUE> - A controllable mock embedding model for testing — v3 naming alias.
- MockImageModelV3
- A controllable mock image model for testing.
- MockLanguageModelV4
- A controllable mock language model for testing.
Functions
-
mockId(
) → String Function() - Returns an incrementing integer ID starting from 0.
-
mockReasoning(
String text) → LanguageModelV4ReasoningPart - Convenience constructor for a mock reasoning content part.
-
mockText(
String text) → LanguageModelV4TextPart - Convenience constructor for a mock text content part.
-
mockToolCall(
{required String toolName, required Object input, String? toolCallId}) → LanguageModelV4ToolCallPart - Convenience constructor for a mock tool call content part.
-
mockValues<
T> (List< T> values) → T Function() -
Returns a function that cycles through
valueson each call.