Repository navigation
Stacked CLI with Mock Services #908
Answered
by
FilledStacks
SeanningTatum
asked this question in
Q&A
|
Hi - I'm a big fan of using "abstraction / mock services" as it really helps with e2e testing and mocking things before creating an API. But I'm struggling to do this in the new stacked cli setup. Future<void> setupLocator(
{String? environment, EnvironmentFilter? environmentFilter}) async {
// Register environments
locator.registerEnvironment(
environment: environment, environmentFilter: environmentFilter);
// Register dependencies
locator.registerLazySingleton(() => BottomSheetService());
locator.registerLazySingleton(() => DialogService());
locator.registerLazySingleton(() => NavigationService());
locator.registerLazySingleton(
() => environment == Environment.dev
? CounterMockService()
: CounterRealService(),
);
}So based on the old video https://www.youtube.com/watch?v=DO8le1W_HqQ, this is generally how we'd switch from using a MockService and a RealService. I was wondering how we would currently set this up with the new cli, as the generators would delete this, and the test generators go crazy. |
Answered by
FilledStacks
Mar 16, 2023
Replies: 1 comment 1 reply
|
@SeanningTatum good question, currently the CLI doesn't support that. But you can do that setup through the LazySingleton(
asType: BaseRouterService,
classType: RouterService,
environments: {Environment.prod},
),
LazySingleton(
asType: BaseRouterService,
classType: MockRouterService,
environments: {Environment.dev, Environment.test},
),Check if that gives you what you're hoping for. |
1 reply
Answer selected by
SeanningTatum
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@SeanningTatum good question, currently the CLI doesn't support that. But you can do that setup through the
StackedAppby doing something like this.Check if that gives you what you're hoping for.