diff --git a/packages/react-router/__tests__/data-memory-router-test.tsx b/packages/react-router/__tests__/data-memory-router-test.tsx index 1d47ae7400..f23d7e73bd 100644 --- a/packages/react-router/__tests__/data-memory-router-test.tsx +++ b/packages/react-router/__tests__/data-memory-router-test.tsx @@ -8,9 +8,8 @@ import { queryByText, } from "@testing-library/react"; import "@testing-library/jest-dom"; -import type { FormMethod, Router, RouterInit } from "@remix-run/router"; +import type { ErrorResponse, FormMethod } from "@remix-run/router"; import { joinPaths } from "@remix-run/router"; -import type { RouteObject } from "react-router"; import { Await, MemoryRouter, @@ -35,39 +34,10 @@ import { UNSAFE_DataRouterContext as DataRouterContext, } from "react-router"; -let router: Router | null = null; - -describe("", () => { +describe("createMemoryRouter", () => { let consoleWarn: jest.SpyInstance; let consoleError: jest.SpyInstance; - // Abstraction to avoid re-writing all tests for the time being - function DataMemoryRouter({ - basename, - children, - fallbackElement, - hydrationData, - initialEntries, - initialIndex, - routes, - }: { - basename?: RouterInit["basename"]; - children?: React.ReactNode | React.ReactNode[]; - fallbackElement?: React.ReactNode; - hydrationData?: RouterInit["hydrationData"]; - initialEntries?: string[]; - initialIndex?: number; - routes?: RouteObject[]; - }) { - router = createMemoryRouter(routes || createRoutesFromElements(children), { - basename, - hydrationData, - initialEntries, - initialIndex, - }); - return ; - } - beforeEach(() => { consoleWarn = jest.spyOn(console, "warn").mockImplementation(() => {}); consoleError = jest.spyOn(console, "error").mockImplementation(() => {}); @@ -76,15 +46,13 @@ describe("", () => { afterEach(() => { consoleWarn.mockRestore(); consoleError.mockRestore(); - router = null; }); it("renders the first route that matches the URL (element)", () => { - let { container } = render( - - Home} /> - + let router = createMemoryRouter( + createRoutesFromElements(Home} />) ); + let { container } = render(); expect(getHtml(container)).toMatchInlineSnapshot(` "
@@ -96,11 +64,12 @@ describe("", () => { }); it("renders the first route that matches the URL (Component)", () => { - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements(

Home

} /> -
+ ) ); + let { container } = render(); expect(getHtml(container)).toMatchInlineSnapshot(` "
@@ -112,19 +81,13 @@ describe("", () => { }); it("supports a `routes` prop instead of children", () => { - let routes = [ + let router = createMemoryRouter([ { path: "/", element:

Home

, }, - ]; - let { container } = render( - - ); + ]); + let { container } = render(); expect(getHtml(container)).toMatchInlineSnapshot(` "
@@ -136,16 +99,17 @@ describe("", () => { }); it("renders the first route that matches the URL when wrapped in a root route", () => { - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( Heyooo} /> - + ), + { + initialEntries: ["/my/base/path/thing"], + } ); + let { container } = render(); expect(getHtml(container)).toMatchInlineSnapshot(` "
@@ -157,15 +121,16 @@ describe("", () => { }); it("supports a basename prop", () => { - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( Heyooo} /> - + ), + { + basename: "/my/base/path", + initialEntries: ["/my/base/path/thing"], + } ); + let { container } = render(); expect(getHtml(container)).toMatchInlineSnapshot(` "
@@ -177,17 +142,19 @@ describe("", () => { }); it("prepends basename to loader/action redirects", async () => { - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( }> redirect("/other")} /> Other} /> - + ), + { + basename: "/my/base/path", + initialEntries: ["/my/base/path"], + } ); + let { container } = render(); function Root() { return ( @@ -225,19 +192,21 @@ describe("", () => { }); it("supports relative routing in loader/action redirects", async () => { - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( }> }> redirect("../other")} /> Other} /> - + ), + { + basename: "/my/base/path", + initialEntries: ["/my/base/path"], + } ); + let { container } = render(); function Root() { return ( @@ -287,10 +256,15 @@ describe("", () => { }); it("renders with hydration data", async () => { - let { container } = render( - }> + } /> + + ), + { + initialEntries: ["/child"], + hydrationData: { loaderData: { "0": "parent data", "0-0": "child data", @@ -298,23 +272,20 @@ describe("", () => { actionData: { "0-0": "child action", }, - }} - > - }> - } /> - - + }, + } ); + let { container } = render(); function Comp() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; let actionData = useActionData(); let navigation = useNavigation(); return (
- {data} - {actionData} - {navigation.state} + <>{data} + <>{actionData} + <>{navigation.state}
); @@ -338,16 +309,19 @@ describe("", () => { it("renders fallbackElement while first data fetch happens", async () => { let fooDefer = createDeferred(); - let { container } = render( - } - initialEntries={["/foo"]} - > + let router = createMemoryRouter( + createRoutesFromElements( }> fooDefer.promise} element={} /> } /> - + ), + { + initialEntries: ["/foo"], + } + ); + let { container } = render( + } /> ); function FallbackElement() { @@ -355,7 +329,7 @@ describe("", () => { } function Foo() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; return

Foo:{data?.message}

; } @@ -385,17 +359,21 @@ describe("", () => { it("renders a null fallbackElement if none is provided", async () => { let fooDefer = createDeferred(); - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( }> fooDefer.promise} element={} /> } /> - + ), + { + initialEntries: ["/foo"], + } ); + let { container } = render(); function Foo() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; return

Foo:{data?.message}

; } @@ -419,16 +397,20 @@ describe("", () => { it("does not render fallbackElement if no data fetch is required", async () => { let fooDefer = createDeferred(); - let { container } = render( - } - initialEntries={["/bar"]} - > + + let router = createMemoryRouter( + createRoutesFromElements( }> fooDefer.promise} element={} /> } /> - + ), + { + initialEntries: ["/bar"], + } + ); + let { container } = render( + } /> ); function FallbackElement() { @@ -436,7 +418,7 @@ describe("", () => { } function Foo() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; return

Foo:{data?.message}

; } @@ -455,15 +437,16 @@ describe("", () => { it("renders fallbackElement within router contexts", async () => { let fooDefer = createDeferred(); - let { container } = render( - } - initialEntries={["/foo"]} - > + let router = createMemoryRouter( + createRoutesFromElements( }> fooDefer.promise} element={} /> - + ), + { initialEntries: ["/foo"] } + ); + let { container } = render( + } /> ); function FallbackElement() { @@ -476,7 +459,7 @@ describe("", () => { } function Foo() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; return

Foo:{data?.message}

; } @@ -502,14 +485,16 @@ describe("", () => { }); it("handles link navigations", async () => { - render( - + let router = createMemoryRouter( + createRoutesFromElements( }> } /> } /> - + ), + { initialEntries: ["/foo"] } ); + render(); function Layout() { return ( @@ -539,15 +524,16 @@ describe("", () => { it("executes route loaders on navigation", async () => { let barDefer = createDeferred(); - - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( }> } /> barDefer.promise} element={} /> - + ), + { initialEntries: ["/foo"] } ); + let { container } = render(); function Layout() { let navigation = useNavigation(); @@ -564,7 +550,7 @@ describe("", () => { return

Foo

; } function Bar() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; return

{data?.message}

; } @@ -632,8 +618,8 @@ describe("", () => { let formData = new FormData(); formData.append("test", "value"); - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( }> } /> ", () => { element={} /> - + ), + { initialEntries: ["/foo"] } ); + let { container } = render(); function Layout() { let navigation = useNavigation(); @@ -663,12 +651,12 @@ describe("", () => { return

Foo

; } function Bar() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; let actionData = useActionData(); return (

- {data} - {actionData} + <>{data} + <>{actionData}

); } @@ -747,8 +735,8 @@ describe("", () => { it("provides useMatches", async () => { let spy = jest.fn(); - render( - + let router = createMemoryRouter( + createRoutesFromElements( }> ", () => { handle={{ key: "value" }} /> - + ) ); + render(); function Layout() { spy("Layout", useMatches()); @@ -832,15 +821,8 @@ describe("", () => { it("provides useRouteLoaderData", async () => { let spy = jest.fn(); - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( }> ", () => { /> - + ), + { + initialEntries: ["/foo"], + hydrationData: { + loaderData: { + foo: "FOO", + }, + }, + } ); + let { container } = render(); function Layout() { spy({ @@ -920,16 +911,8 @@ describe("", () => { it("reloads data using useRevalidate", async () => { let count = 1; - - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( }> ", () => { element={} /> - + ), + { + initialEntries: ["/foo"], + hydrationData: { + loaderData: { + "0-0": "count=1", + }, + }, + } ); + let { container } = render(); function Layout() { let navigation = useNavigation(); @@ -954,7 +946,7 @@ describe("", () => { } function Foo() { - let data = useLoaderData(); + let data = useLoaderData() as string; return

{data}

; } @@ -1019,6 +1011,23 @@ describe("", () => { }); it("renders descendent routes inside a data router", () => { + let router = createMemoryRouter( + createRoutesFromElements( + + } /> + + ), + { + initialEntries: ["/deep/path/to/descendant/routes"], + hydrationData: { + loaderData: { + "0-0": "count=1", + }, + }, + } + ); + let { container } = render(); + function GrandChild() { return ( @@ -1040,17 +1049,6 @@ describe("", () => { ); } - let { container } = render( - - - } /> - - - ); - expect(getHtml(container)).toMatchInlineSnapshot(` "

@@ -1062,10 +1060,19 @@ describe("", () => { describe("errors", () => { it("renders hydration errors on leaf elements using errorElement", async () => { - let { container } = render( - }> + } + errorElement={} + /> + + ), + { + initialEntries: ["/child"], + hydrationData: { loaderData: { "0": "parent data", }, @@ -1075,34 +1082,27 @@ describe("", () => { errors: { "0-0": new Error("Kaboom 💥"), }, - }} - > - }> - } - errorElement={} - /> - - + }, + } ); + let { container } = render(); function Comp() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; let actionData = useActionData(); let navigation = useNavigation(); return (
- {data} - {actionData} - {navigation.state} + <>{data} + <>{actionData} + <>{navigation.state}
); } function ErrorBoundary() { - let error = useRouteError(); + let error = useRouteError() as Error; return

{error.message}

; } @@ -1121,10 +1121,19 @@ describe("", () => { }); it("renders hydration errors on leaf elements using ErrorBoundary", async () => { - let { container } = render( - }> + } + ErrorBoundary={() =>

{(useRouteError() as Error).message}

} + /> +
+ ), + { + initialEntries: ["/child"], + hydrationData: { loaderData: { "0": "parent data", }, @@ -1134,27 +1143,20 @@ describe("", () => { errors: { "0-0": new Error("Kaboom 💥"), }, - }} - > - }> - } - ErrorBoundary={() =>

{useRouteError()?.message}

} - /> -
-
+ }, + } ); + let { container } = render(); function Comp() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; let actionData = useActionData(); let navigation = useNavigation(); return (
- {data} - {actionData} - {navigation.state} + <>{data} + <>{actionData} + <>{navigation.state}
); @@ -1175,39 +1177,41 @@ describe("", () => { }); it("renders hydration errors on parent elements", async () => { - let { container } = render( - } errorElement={}> + } /> + + ), + { + initialEntries: ["/child"], + hydrationData: { loaderData: {}, actionData: null, errors: { "0": new Error("Kaboom 💥"), }, - }} - > - } errorElement={}> - } /> - - + }, + } ); + let { container } = render(); function Comp() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; let actionData = useActionData(); let navigation = useNavigation(); return (
- {data} - {actionData} - {navigation.state} + <>{data} + <>{actionData} + <>{navigation.state}
); } function ErrorBoundary() { - let error = useRouteError(); + let error = useRouteError() as Error; return

{error.message}

; } @@ -1224,17 +1228,8 @@ describe("", () => { let fooDefer = createDeferred(); let barDefer = createDeferred(); - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( }> ", () => { errorElement={} /> - + ), + { + initialEntries: ["/foo"], + hydrationData: { + loaderData: { + "0-0": { + message: "hydrated from foo", + }, + }, + }, + } ); + let { container } = render(); function Layout() { let navigation = useNavigation(); @@ -1265,19 +1271,19 @@ describe("", () => { } function Foo() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; return

Foo:{data?.message}

; } function FooError() { - let error = useRouteError(); + let error = useRouteError() as Error; return

Foo Error:{error.message}

; } function Bar() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; return

Bar:{data?.message}

; } function BarError() { - let error = useRouteError(); + let error = useRouteError() as Error; return

Bar Error:{error.message}

; } @@ -1364,17 +1370,8 @@ describe("", () => { let fooDefer = createDeferred(); let barDefer = createDeferred(); - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( }> ", () => { ErrorBoundary={BarError} /> - + ), + { + initialEntries: ["/foo"], + hydrationData: { + loaderData: { + "0-0": { + message: "hydrated from foo", + }, + }, + }, + } ); + let { container } = render(); function Layout() { let navigation = useNavigation(); @@ -1405,19 +1413,19 @@ describe("", () => { } function Foo() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; return

Foo:{data?.message}

; } function FooError() { - let error = useRouteError(); + let error = useRouteError() as Error; return

Foo Error:{error.message}

; } function Bar() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; return

Bar:{data?.message}

; } function BarError() { - let error = useRouteError(); + let error = useRouteError() as Error; return

Bar Error:{error.message}

; } @@ -1504,17 +1512,8 @@ describe("", () => { let fooDefer = createDeferred(); let barDefer = createDeferred(); - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( } errorElement={}> ", () => { element={} /> - + ), + { + initialEntries: ["/foo"], + hydrationData: { + loaderData: { + "0-0": { + message: "hydrated from foo", + }, + }, + }, + } ); + let { container } = render(); function Layout() { let navigation = useNavigation(); @@ -1543,19 +1553,19 @@ describe("", () => { ); } function LayoutError() { - let error = useRouteError(); + let error = useRouteError() as Error; return

Layout Error:{error.message}

; } function Foo() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; return

Foo:{data?.message}

; } function FooError() { - let error = useRouteError(); + let error = useRouteError() as Error; return

Foo Error:{error.message}

; } function Bar() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; return

Bar:{data?.message}

; } @@ -1597,42 +1607,46 @@ describe("", () => { }); it("renders 404 errors using path='/' error boundary", async () => { - let { container } = render( - + Thing 1

} + errorElement={

Not I!

} + /> + +

Hello

+ +
+ } + errorElement={} + /> + + ), + { + initialEntries: ["/foo"], + hydrationData: { loaderData: { "0": { message: "hydrated from foo", }, }, - }} - > - Thing 1} - errorElement={

Not I!

} - /> - -

Hello

- -
- } - errorElement={} - /> -
+ }, + } ); + let { container } = render(); function Boundary() { - let error = useRouteError(); + let error = useRouteError() as ErrorResponse; return (

Error: - {error.status} - {error.statusText} + <>{error.status} + <>{error.statusText}

); } @@ -1649,42 +1663,46 @@ describe("", () => { }); it("renders 404 errors using index error boundary", async () => { - let { container } = render( - + Thing 1} + errorElement={

Not I!

} + /> + +

Hello

+ +
+ } + errorElement={} + /> + + ), + { + initialEntries: ["/foo"], + hydrationData: { loaderData: { "0": { message: "hydrated from foo", }, }, - }} - > - Thing 1} - errorElement={

Not I!

} - /> - -

Hello

- -
- } - errorElement={} - /> -
+ }, + } ); + let { container } = render(); function Boundary() { - let error = useRouteError(); + let error = useRouteError() as ErrorResponse; return (

Error: - {error.status} - {error.statusText} + <>{error.status} + <>{error.statusText}

); } @@ -1701,29 +1719,33 @@ describe("", () => { }); it("renders 404 errors using fallback boundary if no root layout route exists", async () => { - let { container } = render( - + Thing 1} + errorElement={

Not I!

} + /> + Thing 2} + errorElement={

Not I!

} + /> + + ), + { + initialEntries: ["/foo"], + hydrationData: { loaderData: { "0": { message: "hydrated from foo", }, }, - }} - > - Thing 1} - errorElement={

Not I!

} - /> - Thing 2} - errorElement={

Not I!

} - /> -
+ }, + } ); + let { container } = render(); expect(getHtml(container)).toMatchInlineSnapshot(` "
@@ -1760,17 +1782,8 @@ describe("", () => { let fooDefer = createDeferred(); let barDefer = createDeferred(); - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( }> ", () => { element={} /> - + ), + { + initialEntries: ["/foo"], + hydrationData: { + loaderData: { + "0-0": { + message: "hydrated from foo", + }, + }, + }, + } ); + let { container } = render(); function Layout() { let navigation = useNavigation(); @@ -1798,11 +1822,11 @@ describe("", () => { ); } function Foo() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; return

Foo:{data?.message}

; } function Bar() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; return

Bar:{data?.message}

; } @@ -1894,9 +1918,8 @@ describe("", () => { }, ]; - let { container } = render( - - ); + let router = createMemoryRouter(routes, { initialEntries: ["/foo"] }); + let { container } = render(); function Layout() { let navigation = useNavigation(); @@ -1909,11 +1932,11 @@ describe("", () => { ); } function Bar() { - let data = useLoaderData(); + let data = useLoaderData() as { message: string }; return

Bar:{data?.message}

; } function BarError() { - let error = useRouteError(); + let error = useRouteError() as Error; return

Bar Error:{error.message}

; } @@ -1959,14 +1982,8 @@ describe("", () => { }); it("handles render errors in parent errorElement", async () => { - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( ", () => { > } /> - + ), + { initialEntries: ["/child"] } ); + let { container } = render(); function ChildComp(): React.ReactElement { throw new Error("Kaboom!"); } function ErrorBoundary() { - let error = useRouteError(); + let error = useRouteError() as Error; return

{error.message}

; } @@ -2001,14 +2020,8 @@ describe("", () => { }); it("handles render errors in child errorElement", async () => { - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( ", () => { errorElement={} /> - + ), + { initialEntries: ["/child"] } ); + let { container } = render(); function ChildComp(): React.ReactElement { throw new Error("Kaboom!"); } function ErrorBoundary() { - let error = useRouteError(); + let error = useRouteError() as Error; return

{error.message}

; } @@ -2052,14 +2067,8 @@ describe("", () => { }); it("handles render errors in default errorElement", async () => { - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( ", () => { > } /> - + ), + { initialEntries: ["/child"] } ); + let { container } = render(); function ChildComp(): React.ReactElement { let error = new Error("Kaboom!"); @@ -2178,7 +2189,7 @@ describe("", () => { } function ErrorBoundary() { - let error = useRouteError(); + let error = useRouteError() as Error; return

{error.message}

; } @@ -2318,8 +2329,8 @@ describe("", () => { it("does not allow loaderData usage in self-caught error boundaries", async () => { let errorSpy = jest.spyOn(console, "error"); - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( }> ", () => { errorElement={} /> - + ) ); + let { container } = render(); function Layout() { let navigation = useNavigation(); @@ -2343,8 +2355,8 @@ describe("", () => { } function FooError() { - let error = useRouteError(); - let data = useLoaderData(); + let error = useRouteError() as Error; + let data = useLoaderData() as { message: string }; return ( <>

@@ -2404,14 +2416,8 @@ describe("", () => { it("does not allow useLoaderData usage in bubbled error boundaries", async () => { let errorSpy = jest.spyOn(console, "error"); - let { container } = render( - + let router = createMemoryRouter( + createRoutesFromElements( } @@ -2424,8 +2430,16 @@ describe("", () => { element={

Foo

} /> -
+ ), + { + hydrationData: { + loaderData: { + "0": "ROOT", + }, + }, + } ); + let { container } = render(); function Layout() { let navigation = useNavigation(); @@ -2438,8 +2452,8 @@ describe("", () => { ); } function LayoutError() { - let data = useLoaderData(); - let error = useRouteError(); + let data = useLoaderData() as { message: string }; + let error = useRouteError() as Error; return ( <>

@@ -2499,8 +2513,9 @@ describe("", () => { let awaitRenderCount = 0; let barDefer = createDeferred(); let bazDefer = createDeferred(); - let { container } = render( - + + let router = createMemoryRouter( + createRoutesFromElements( }> Foo} /> ", () => { element={

Baz

} /> -
+ ), + { initialEntries: ["/foo"] } ); + let { container } = render(); function Layout() { let navigation = useNavigation(); @@ -2533,7 +2550,7 @@ describe("", () => { } function Bar() { - let data = useLoaderData(); + let data = useLoaderData() as { critical: string }; return ( <>

{data.critical}

@@ -2559,12 +2576,13 @@ describe("", () => { } function RouteError() { - let error = useRouteError(); + let error = useRouteError() as Error; return

Route Error:{error.message}

; } function LazyFallback() { return triggerFallbackError ? ( + // @ts-expect-error

{oops.i.did.it}

) : (

Loading...

@@ -2572,8 +2590,9 @@ describe("", () => { } function LazyData() { - let data = useAsyncValue(); + let data = useAsyncValue() as string; return triggerRenderError ? ( + // @ts-expect-error

{oops.i.did.it.again}

) : (

{data}

@@ -2581,12 +2600,12 @@ describe("", () => { } function LazyError() { - let data = useAsyncError(); + let data = useAsyncError() as Error; return

Await Error:{data.message}

; } return { - container: container.querySelector("#content"), + container: container.querySelector("#content") as HTMLElement, barDefer, bazDefer, getAwaitRenderCount() { @@ -3128,28 +3147,37 @@ describe("", () => { it("should permit direct access to resolved values", async () => { let barDefer = createDeferred(); - let { container } = render( - - -

Foo

- Link to bar - - } - /> - barDefer.promise} element={} /> -
+ + let router = createMemoryRouter( + createRoutesFromElements( + <> + +

Foo

+ Link to bar + + } + /> + barDefer.promise} + element={} + /> + + ), + { initialEntries: ["/foo"] } ); + let { container } = render(); let count = 0; function Bar() { - let { bar } = useLoaderData(); + let { bar } = useLoaderData() as { bar: Promise }; React.useEffect(() => { bar.then((data) => { - container.querySelector("#content").innerHTML = + container.querySelector("#content")!.innerHTML = data + " " + ++count; }); }, [bar]); @@ -3225,8 +3253,8 @@ describe("", () => { ); function ErrorElement() { - let error = useAsyncError() as string; - return

Error:{error}

; + let error = useAsyncError() as Error; + return

Error:{error.message}

; } expect(getHtml(container)).toMatchInlineSnapshot(` @@ -3237,7 +3265,7 @@ describe("", () => {
" `); - await dfd.reject("REJECTED"); + await dfd.reject(new Error("REJECTED")); await waitFor(() => screen.getByText("Error:REJECTED")); expect(getHtml(container)).toMatchInlineSnapshot(` "