Skip to main content

MockConfigApi

Home > @backstage/test-utils > MockConfigApi

MockConfigApi is a thin wrapper around ConfigReader that can be used to mock configuration using a plain object.

Signature:

class MockConfigApi implements ConfigApi 

Implements: ConfigApi

Example

const mockConfig = new MockConfigApi({
app: { baseUrl: 'https://example.com' },
});

const rendered = await renderInTestApp(
<TestApiProvider apis={[[configApiRef, mockConfig]]}>
<MyTestedComponent />
</TestApiProvider>,
);

Constructors

ConstructorModifiersDescription
(constructor)(data)Constructs a new instance of the MockConfigApi class

Methods

MethodModifiersDescription
get(key)
getBoolean(key)
getConfig(key)
getConfigArray(key)
getNumber(key)
getOptional(key)
getOptionalBoolean(key)
getOptionalConfig(key)
getOptionalConfigArray(key)
getOptionalNumber(key)
getOptionalString(key)
getOptionalStringArray(key)
getString(key)
getStringArray(key)
has(key)
keys()