Skip to main content
Version: Next

ServiceFactoryTester.getService()

Home > @backstage/backend-test-utils > ServiceFactoryTester > getService

Return the service instance for any of the provided dependencies or built-in services.

Signature:

getService<TGetService, TGetScope extends 'root' | 'plugin', TGetInstances extends 'singleton' | 'multiton' = 'singleton'>(service: ServiceRef<TGetService, TGetScope, TGetInstances>, ...args: 'root' extends TGetScope ? [] : [pluginId?: string]): Promise<TGetInstances extends 'multiton' ? TGetService[] : TGetService>;

Parameters

ParameterTypeDescription
serviceServiceRef<TGetService, TGetScope, TGetInstances>
args'root' extends TGetScope ? [] : [pluginId?: string]

Returns:

Promise<TGetInstances extends 'multiton' ? TGetService[] : TGetService>

Remarks

A plugin ID can optionally be provided for plugin scoped services, otherwise the plugin ID 'test' is used.