Skip to main content

TechDocsAddonTester

Home > @backstage/plugin-techdocs-addons-test-utils > TechDocsAddonTester

Utility class for rendering TechDocs Addons end-to-end within the TechDocs reader page, with a set of givens (e.g. page DOM, metadata, etc).

Signature:

class TechDocsAddonTester 

Example

const { getByText } = await TechDocsAddonTester.buildAddonsInTechDocs([<AnAddon />])
.withDom(<body>TEST_CONTENT</body>)
.renderWithEffects();

expect(getByText('TEST_CONTENT')).toBeInTheDocument();

Constructors

Constructor

Modifiers

Description

(constructor)(addons)

protected

Constructs a new instance of the TechDocsAddonTester class

Methods

Method

Modifiers

Description

atPath(path)

Provide the TechDocs page path at which the Addon is rendered (e.g. the part of the path after the entity namespace/kind/name).

build()

Return a fully configured and mocked TechDocs reader page within a test App instance, using the given Addon(s).

buildAddonsInTechDocs(addons)

static

Get a TechDocsAddonTester instance for a given set of Addons.

renderWithEffects()

Render the Addon within a fully configured and mocked TechDocs reader.

withApis(apis)

Provide mock API implementations if your Addon expects any.

withDom(dom)

Provide mock HTML if your Addon expects it in the shadow DOM.

withEntity(entity)

Provide a mock entity if your Addon needs it. This also controls the base path at which the Addon is rendered.

withMetadata(metadata)

Provide mock techdocs_metadata.json values if your Addon needs it.