Skip to main content

TestApiRegistry.from()

Home > @backstage/test-utils > TestApiRegistry > from

Creates a new TestApiRegistry with a list of API implementation pairs.

Similar to the TestApiProvider(), there is no need to provide a full implementation of each API, it's enough to implement the methods that are tested.

Signature:

static from<TApiPairs extends any[]>(...apis: readonly [...TestApiProviderPropsApiPairs<TApiPairs>]): TestApiRegistry;

Parameters

Parameter

Type

Description

apis

readonly [...TestApiProviderPropsApiPairs<TApiPairs>]

A list of pairs mapping an ApiRef to its respective implementation.

**Returns:**

TestApiRegistry

Example

const apis = TestApiRegistry.from(
[configApiRef, new ConfigReader({})],
[identityApiRef, { getUserId: () => 'tester' }],
);