mockLazy<T> method
Replace a dependency with a factory function
Useful when you need to create a new instance for each test.
By default, creates a singleton on first access.
Set alwaysNew to true to create fresh instance each time.
Implementation
ZenTestMode mockLazy<T>(
T Function() factory, {
String? tag,
bool alwaysNew = false,
}) {
ZenLogger.logDebug(
'🧪 Test Mode: Mocking $T${tag != null ? ':$tag' : ''} (${alwaysNew ? 'always new' : 'lazy singleton'})');
Zen.delete<T>(tag: tag, force: true);
Zen.putLazy<T>(factory, tag: tag, alwaysNew: alwaysNew);
return this;
}