mockId function

String Function() mockId()

Returns an incrementing integer ID starting from 0.

Each call to the returned function produces the next integer as a string. Mirrors mockId from the JS AI SDK v6 ai/test sub-path.

final id = mockId();
expect(id(), '0');
expect(id(), '1');

Implementation

String Function() mockId() {
  var counter = 0;
  return () => '${counter++}';
}