Remove mountPath → initialRouteEntries defaulting

Don't auto-default initialRouteEntries from mountPath — for
parameterized paths this silently produces wrong params (literal
':name' values). Require callers to set both explicitly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2026-05-25 15:18:11 +02:00
parent fcde31d871
commit 7efdc27464
@@ -82,12 +82,10 @@ export type TestAppOptions<TApiPairs extends any[] = any[]> = {
/**
* The route path pattern that the test element is rendered at. When set,
* the element is wrapped in a `<Route>` with this path, enabling
* `useParams()` to extract parameters from the URL. Defaults to `'/'`.
* `useParams()` to extract parameters from the URL.
*
* When `mountPath` is set and `initialRouteEntries` is not, the
* initial route entry defaults to `mountPath` (which works for paths
* without parameters). For parameterized paths you must also set
* `initialRouteEntries` to a concrete URL that matches the pattern.
* Should be used together with `initialRouteEntries` to set a concrete
* URL that matches the pattern.
*
* @example
* ```ts
@@ -100,8 +98,7 @@ export type TestAppOptions<TApiPairs extends any[] = any[]> = {
mountPath?: string;
/**
* Initial route entries to use for the router. When `mountPath` is set
* and this is not, defaults to `[mountPath]`.
* Initial route entries to use for the router.
*/
initialRouteEntries?: string[];
@@ -214,10 +211,7 @@ export function renderInTestApp<const TApiPairs extends any[] = any[]>(
params: {
component: ({ children }) => (
<MemoryRouter
initialEntries={
options?.initialRouteEntries ??
(mountPath ? [mountPath] : undefined)
}
initialEntries={options?.initialRouteEntries}
future={{
v7_relativeSplatPath: false,
v7_startTransition: false,