Add extension snapshot testing support to frontend-test-utils

Adds the snapshot() method to ExtensionTester, enabling snapshot
testing of extension tree structures. The snapshots use a tree-shaped
format that mirrors the extension hierarchy, with empty fields and
default values omitted for clarity.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2026-02-02 01:30:22 +01:00
parent a5e536d899
commit 15ed3f9ccb
7 changed files with 297 additions and 2 deletions
@@ -200,8 +200,6 @@ describe('Index page', () => {
});
```
That's all for testing features!
## Mounting routes
If your component or extension uses `useRouteRef` to generate links to other routes, you need to mount those routes in the test environment. Both `renderInTestApp` and `renderTestApp` support the `mountedRoutes` option for this purpose.
@@ -243,6 +241,10 @@ describe('MyComponent', () => {
});
```
## Extension tree snapshots
The `snapshot()` method on `ExtensionTester` returns a tree-shaped representation of the resolved extension hierarchy, which is convenient to use with Jest's `toMatchInlineSnapshot()` for verifying extension structure in tests.
## Missing something?
If there's anything else you think needs to be covered in the docs or that you think isn't covered by the test utilities, please create an issue in the Backstage repository. You are always welcome to contribute as well!