Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
- david-bezero
- david-crespo
- dcblair
- dchenk
- decadentsavant
- dgrijuela
- DigitalNaut
Expand Down
75 changes: 75 additions & 0 deletions packages/react-router/__tests__/router/lazy-discovery-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,81 @@ describe("Lazy Route Discovery (Fog of War)", () => {
expect(router.state.matches.map((m) => m.route.id)).toEqual(["a", "b"]);
});

it("handles errors thrown from patchRoutesOnNavigation() when there are no partial matches (GET navigation)", async () => {
router = createRouter({
history: createMemoryHistory(),
routes: [
{
id: "a",
path: "a",
},
],
async patchRoutesOnNavigation({ patch }) {
await tick();
throw new Error("broke!");
patch("b", [
{
id: "b",
path: "b",
loader() {
return "B";
},
},
]);
},
});

await router.navigate("/b");
expect(router.state).toMatchObject({
matches: [],
location: { pathname: "/b" },
actionData: null,
loaderData: {},
errors: {
a: new Error("broke!"),
},
});
});

it("handles errors thrown from patchRoutesOnNavigation() when there are no partial matches (POST navigation)", async () => {
router = createRouter({
history: createMemoryHistory(),
routes: [
{
id: "a",
path: "a",
},
],
async patchRoutesOnNavigation({ patch }) {
await tick();
throw new Error("broke!");
patch("b", [
{
id: "b",
path: "b",
action() {
return "B";
},
},
]);
},
});

await router.navigate("/b", {
formMethod: "POST",
formData: createFormData({}),
});
expect(router.state).toMatchObject({
matches: [],
location: { pathname: "/b" },
actionData: null,
loaderData: {},
errors: {
a: new Error("broke!"),
},
});
});

it("bubbles errors thrown from patchRoutesOnNavigation() during hydration", async () => {
router = createRouter({
history: createMemoryHistory({
Expand Down
Loading