@backstage/test-utils
Utilities to test Backstage plugins and apps.
Classes
Class |
Description |
---|---|
Mock implementation of AnalyticsApi with helpers to ensure that events are sent correctly. Use getEvents in tests to verify captured events. | |
MockConfigApi is a thin wrapper around ConfigReader that can be used to mock configuration using a plain object. | |
Mock implementation of the ErrorApi to be used in tests. Includes withForError and getErrors methods for error testing. | |
A test helper implementation of FetchApi. | |
Mock implementation of PermissionApi. Supply a requestHandler function to override the mock result returned for a given request. | |
Mock implementation of the StorageApi to be used in tests | |
The |
Functions
Function |
Description |
---|---|
Creates a Wrapper component that wraps a component inside a Backstage test app, providing a mocked theme and app context, along with mocked APIs. | |
This is a mocking method suggested in the Jest docs, as it is not implemented in JSDOM yet. It can be used to mock values for the Material UI For issues checkout the documentation: https://jestjs.io/docs/manual-mocks\#mocking-methods-which-are-not-implemented-in-jsdom If there are any updates from Material UI React on testing | |
Sets up handlers for request mocking | |
Renders a component inside a Backstage test app, providing a mocked theme and app context, along with mocked APIs. The render executes async effects similar to | |
Simplifies rendering of async components in by taking care of the wrapping inside act | |
The It lets you provide any number of API implementations, without necessarily having to fully implement each of the APIs. | |
Returns a | |
Asynchronous log collector with that collects all categories | |
Synchronous log collector with that collects all categories | |
Asynchronous log collector with that only collects selected categories | |
Synchronous log collector with that only collects selected categories | |
Wraps a component inside a Backstage test app, providing a mocked theme and app context, along with mocked APIs. |
Interfaces
Interface |
Description |
---|---|
The options given when constructing a MockFetchApi. |
Namespaces
Namespace |
Description |
---|---|
Mock implementations of the core utility APIs, to be used in tests. |
Type Aliases
Type Alias |
Description |
---|---|
Represents a mocked version of an API, where you automatically have access to the mocked versions of all of its methods along with a factory that returns that same mock. | |
AsyncLogCollector type used in withLogCollector() callback function. | |
Map of severity level and corresponding log lines. | |
ErrorWithContext contains error and ErrorApiErrorContext | |
Set legacy mode when using React 18/RTL 13+. Mock this option while we're working against React 17 or lower. | |
Union type used in withLogCollector() callback function. | |
Severity levels of CollectedLogs | |
Constructor arguments for MockErrorApi | |
Type for map holding data in MockStorageApi | |
SyncLogCollector type used in withLogCollector() callback function. | |
Properties for the TestApiProvider() component. | |
Options to customize the behavior of the test app wrapper. |