|
1 | 1 | import { test, expect } from "@playwright/test";
|
2 | 2 |
|
| 3 | +import { ServerMode } from "../packages/remix-server-runtime/mode.js"; |
3 | 4 | import {
|
4 | 5 | createAppFixture,
|
5 | 6 | createFixture,
|
@@ -724,6 +725,61 @@ test.describe("Client Data", () => {
|
724 | 725 | html = await app.getHtml("main");
|
725 | 726 | expect(html).toMatch("Child Server Loader Data (2+) (mutated by client)");
|
726 | 727 | });
|
| 728 | + |
| 729 | + test("server loader errors are re-thrown from serverLoader()", async ({ |
| 730 | + page, |
| 731 | + }) => { |
| 732 | + let _consoleError = console.error; |
| 733 | + console.error = () => {}; |
| 734 | + appFixture = await createAppFixture( |
| 735 | + await createFixture( |
| 736 | + { |
| 737 | + files: { |
| 738 | + ...getFiles({ |
| 739 | + parentClientLoader: false, |
| 740 | + parentClientLoaderHydrate: false, |
| 741 | + childClientLoader: false, |
| 742 | + childClientLoaderHydrate: false, |
| 743 | + }), |
| 744 | + "app/routes/parent.child.tsx": js` |
| 745 | + import { ClientLoaderFunctionArgs, useRouteError } from "@remix-run/react"; |
| 746 | +
|
| 747 | + export function loader() { |
| 748 | + throw new Error("Broken!") |
| 749 | + } |
| 750 | +
|
| 751 | + export async function clientLoader({ serverLoader }) { |
| 752 | + return await serverLoader(); |
| 753 | + } |
| 754 | + clientLoader.hydrate = true; |
| 755 | +
|
| 756 | + export default function Index() { |
| 757 | + return <h1>Should not see me</h1>; |
| 758 | + } |
| 759 | +
|
| 760 | + export function ErrorBoundary() { |
| 761 | + let error = useRouteError(); |
| 762 | + return <p id="child-error">{error.message}</p>; |
| 763 | + } |
| 764 | + `, |
| 765 | + }, |
| 766 | + }, |
| 767 | + ServerMode.Development // Avoid error sanitization |
| 768 | + ), |
| 769 | + ServerMode.Development // Avoid error sanitization |
| 770 | + ); |
| 771 | + let app = new PlaywrightFixture(appFixture, page); |
| 772 | + |
| 773 | + await app.goto("/parent/child"); |
| 774 | + let html = await app.getHtml("main"); |
| 775 | + expect(html).toMatch("Broken!"); |
| 776 | + // Ensure we hydrate and remain on the boundary |
| 777 | + await new Promise((r) => setTimeout(r, 100)); |
| 778 | + html = await app.getHtml("main"); |
| 779 | + expect(html).toMatch("Broken!"); |
| 780 | + expect(html).not.toMatch("Should not see me"); |
| 781 | + console.error = _consoleError; |
| 782 | + }); |
727 | 783 | });
|
728 | 784 |
|
729 | 785 | test.describe("clientLoader - lazy route module", () => {
|
|
0 commit comments