frontend-test-utils: api-reports

Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
Vincenzo Scamporlino
2025-10-07 21:44:36 +02:00
parent c41dd803c6
commit 6c23efd539
2 changed files with 24 additions and 0 deletions
@@ -29,6 +29,7 @@ import { RouteRef } from '@backstage/frontend-plugin-api';
import { TestApiProvider } from '@backstage/test-utils';
import { TestApiProviderProps } from '@backstage/test-utils';
import { TestApiRegistry } from '@backstage/test-utils';
import { testingLibraryDomTypesQueries } from '@testing-library/dom/types/queries';
import { withLogCollector } from '@backstage/test-utils';
export { ApiMock };
@@ -119,6 +120,18 @@ export function renderInTestApp(
options?: TestAppOptions,
): RenderResult;
// @public
export function renderTestApp(
options: RenderTestAppOptions,
): RenderResult<testingLibraryDomTypesQueries, HTMLElement, HTMLElement>;
// @public
export type RenderTestAppOptions = {
config?: JsonObject;
extensions: ExtensionDefinition<any>[];
features?: FrontendFeature[];
};
export { TestApiProvider };
export { TestApiProviderProps };
@@ -26,6 +26,11 @@ import appPlugin from '@backstage/plugin-app';
import { JsonObject } from '@backstage/types';
import { ConfigReader } from '@backstage/config';
/**
* Options for `renderTestApp`.
*
* @public
*/
export type RenderTestAppOptions = {
/**
* Additional configuration passed to the app when rendering elements inside it.
@@ -50,6 +55,12 @@ const appPluginOverride = appPlugin.withOverrides({
],
});
/**
* Renders the provided extensions inside a Backstage app, returning the same
* utilities as `@testing-library/react` `render` function.
*
* @public
*/
export function renderTestApp(options: RenderTestAppOptions) {
const features: FrontendFeature[] = [
createFrontendPlugin({