@@ -5,12 +5,15 @@
|
||||
Deprecate the `.render` method of the `createExtensionTester` in favour of using `renderInTestApp` directly.
|
||||
|
||||
```tsx
|
||||
import { renderInTestApp, createExtensionTester } from '@backstage/frontend-test-utils';
|
||||
import {
|
||||
renderInTestApp,
|
||||
createExtensionTester,
|
||||
} from '@backstage/frontend-test-utils';
|
||||
|
||||
const tester = createExtensionTester(extension);
|
||||
|
||||
const { getByTestId } = renderInTestApp(tester.element());
|
||||
|
||||
// or if you're not using `coreExtensionData.reactElement` as the output ref
|
||||
const { getByTestId } = renderInTestApp(tester.data(myComponentRef))'
|
||||
const { getByTestId } = renderInTestApp(tester.data(myComponentRef));
|
||||
```
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
import React from 'react';
|
||||
import { createRouteRef } from '../routing';
|
||||
import { PageBlueprint } from './PageBlueprint';
|
||||
import { createExtensionTester } from '@backstage/frontend-test-utils';
|
||||
import {
|
||||
createExtensionTester,
|
||||
renderInTestApp,
|
||||
} from '@backstage/frontend-test-utils';
|
||||
import {
|
||||
coreExtensionData,
|
||||
createExtensionBlueprint,
|
||||
@@ -144,7 +147,7 @@ describe('PageBlueprint', () => {
|
||||
CardBlueprint.make({ name: 'card', params: {} }),
|
||||
);
|
||||
|
||||
const { getByTestId, getByText } = tester.render();
|
||||
const { getByTestId, getByText } = renderInTestApp(tester.element());
|
||||
|
||||
await waitFor(() => expect(getByTestId('card')).toBeInTheDocument());
|
||||
await waitFor(() =>
|
||||
|
||||
@@ -27,7 +27,6 @@ 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';
|
||||
|
||||
// @public (undocumented)
|
||||
@@ -100,7 +99,7 @@ export { registerMswTestHooks };
|
||||
export function renderInTestApp(
|
||||
element: JSX.Element,
|
||||
options?: TestAppOptions,
|
||||
): RenderResult<testingLibraryDomTypesQueries, HTMLElement, HTMLElement>;
|
||||
): RenderResult;
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
export function setupRequestMockHandlers(worker: {
|
||||
|
||||
@@ -43,6 +43,7 @@ import { resolveAppNodeSpecs } from '../../../frontend-app-api/src/tree/resolveA
|
||||
import { instantiateAppNodeTree } from '../../../frontend-app-api/src/tree/instantiateAppNodeTree';
|
||||
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
|
||||
import { readAppExtensionsConfig } from '../../../frontend-app-api/src/tree/readAppExtensionsConfig';
|
||||
import { TestAppNavExtension } from './renderInTestApp';
|
||||
|
||||
/** @public */
|
||||
export class ExtensionQuery {
|
||||
@@ -227,6 +228,7 @@ export class ExtensionTester {
|
||||
<MemoryRouter>{children}</MemoryRouter>
|
||||
),
|
||||
}),
|
||||
TestAppNavExtension,
|
||||
],
|
||||
}),
|
||||
],
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import React from 'react';
|
||||
import { Link, MemoryRouter } from 'react-router-dom';
|
||||
import { createSpecializedApp } from '@backstage/frontend-app-api';
|
||||
import { render } from '@testing-library/react';
|
||||
import { RenderResult, render } from '@testing-library/react';
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import {
|
||||
@@ -81,7 +81,7 @@ const NavItem = (props: {
|
||||
);
|
||||
};
|
||||
|
||||
const TestAppNavExtension = createExtension({
|
||||
export const TestAppNavExtension = createExtension({
|
||||
namespace: 'app',
|
||||
name: 'nav',
|
||||
attachTo: { id: 'app/layout', input: 'nav' },
|
||||
@@ -122,7 +122,7 @@ const TestAppNavExtension = createExtension({
|
||||
export function renderInTestApp(
|
||||
element: JSX.Element,
|
||||
options?: TestAppOptions,
|
||||
) {
|
||||
): RenderResult {
|
||||
const extensions: Array<ExtensionDefinition<any, any>> = [
|
||||
createExtension({
|
||||
namespace: 'test',
|
||||
|
||||
Reference in New Issue
Block a user