The container token to replace: an @Injectable({ token })
value, or the token the decorator derived for the class.
The double: { useValue }, { useFactory } or { useClass }
Optionaloptions: ProviderOptions<T>
Lifecycle scope for the double
A plugin to append to createTestApp's overrides, or to pass to
app.register() on an un-started application
During start(). From register() if the application has no
DI container, or if the real provider was registered first (the double would
never be resolved). From an onInit hook if nothing in the application
registered or asked for token, which is how a mistyped token surfaces.
Replaces a provider in the application's dependency-injection container with a test double, before anything is constructed from it.
overrideCapabilityreplaces a capability in the kernel's service registry. WithDiPluginregistered,DecoratorPluginputs each@Injectableclass into the CONTAINER instead, where that cannot reach it, and the container refuses a second registration of a token. This plugin registers the double on the container first and stands in for the container while the rest of the application registers, so the application's own registration of the real provider is skipped and every class that injects the token — a controller included — is constructed with the double.The plugin depends on
CAPABILITIES.DI_CONTAINER, so the kernel orders it afterDiPlugin, and registers atPLUGIN_PRIORITY.NORMAL, ahead ofDecoratorPlugin(PLUGIN_PRIORITY.LOW).