From 62dd4fc3bc027d5664d13e2e50caf8bef4f0673c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Wed, 20 May 2026 10:29:27 +0200 Subject: [PATCH] Add changeset for renderInTestApp route matching fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Fredrik Adelöw --- .changeset/fix-test-route-matching.md | 5 +++++ packages/frontend-test-utils/src/app/renderInTestApp.tsx | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/fix-test-route-matching.md diff --git a/.changeset/fix-test-route-matching.md b/.changeset/fix-test-route-matching.md new file mode 100644 index 0000000000..4f69688f86 --- /dev/null +++ b/.changeset/fix-test-route-matching.md @@ -0,0 +1,5 @@ +--- +'@backstage/frontend-test-utils': patch +--- + +Fixed `renderInTestApp` to set up React Router route matching when `mountedRoutes` are provided. Previously, mounted routes only fed the route resolution API for link generation (`useRouteRef`), but did not create `` elements for param extraction (`useParams`). This meant that `initialRouteEntries` had no effect on route param availability. The test element is now wrapped in `` with a `` for each mounted path, matching the behavior of the real `AppRoutes` extension. diff --git a/packages/frontend-test-utils/src/app/renderInTestApp.tsx b/packages/frontend-test-utils/src/app/renderInTestApp.tsx index 170d6d7294..07dccd9eee 100644 --- a/packages/frontend-test-utils/src/app/renderInTestApp.tsx +++ b/packages/frontend-test-utils/src/app/renderInTestApp.tsx @@ -135,6 +135,7 @@ export function renderInTestApp( output: [coreExtensionData.reactElement], factory: () => { let content: JSX.Element = element; + if (mountedPaths.length > 0) { content = ( @@ -142,13 +143,14 @@ export function renderInTestApp( ))} - + ); } + return [coreExtensionData.reactElement(content)]; }, }),