Skip to content

Commit

Permalink
Update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Jul 30, 2024
1 parent 724d05b commit 1185365
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
8 changes: 6 additions & 2 deletions .changeset/weak-goats-cross.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@

Add `react-router/dom` subpath export to properly enable `react-dom` as an optional `peerDependency`

- This ensures that we don't blindly `import ReactDOM from "react-dom"` in `<RouterProvider>` in order to access `ReactDOM.flushSync()`, since that would break `createMemoryRouter` use cases in a non-DOM environment
- DOM users should `import { RouterProvider } from 'react-router/dom'` to get the proper component that makes `ReactDOM.flushSync()` available
- This ensures that we don't blindly `import ReactDOM from "react-dom"` in `<RouterProvider>` in order to access `ReactDOM.flushSync()`, since that would break `createMemoryRouter` use cases in non-DOM environments
- DOM environments should import from `react-router/dom` to get the proper component that makes `ReactDOM.flushSync()` available:
- If you are using the Vite plugin, use this in your `entry.client.tsx`:
- `import { HydratedRouter } from 'react-router/dom'`
- If you are not using the Vite plugin and are manually calling `createBrowserRouter`/`createHashRouter`:
- `import { RouterProvider } from "react-router/dom"`
14 changes: 7 additions & 7 deletions integration/vite-basename-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ test.describe("Vite base / React Router basename / express dev", async () => {
});

test("works when base and basename are different", async ({ page }) => {
await setup({ base: "/mybase/", basename: "/mybase/app/" });
await workflowDev({ page, cwd, port, basename: "/mybase/app/" });
await setup({ base: "/mybase/", basename: "/mybase/dashboard/" });
await workflowDev({ page, cwd, port, basename: "/mybase/dashboard/" });
});

test("works when basename does not start with base", async ({ page }) => {
Expand Down Expand Up @@ -361,9 +361,9 @@ async function workflowDev({

let isAssetRequest = (url: string) =>
/\.[jt]sx?/.test(url) ||
/@id\/__x00__virtual:/.test(url) ||
/@vite\/client/.test(url) ||
/node_modules\/vite\/dist\/client\/env/.test(url);
/\/@id\/__x00__virtual:/.test(url) ||
/\/@vite\/client/.test(url) ||
/\/@fs\//.test(url);

// verify client asset requests are all under base
expect(
Expand Down Expand Up @@ -413,8 +413,8 @@ test.describe("Vite base / React Router basename / vite build", () => {
});

test("works when base and basename are different", async ({ page }) => {
await setup({ base: "/mybase/", basename: "/mybase/app/" });
await workflowBuild({ page, port, basename: "/mybase/app/" });
await setup({ base: "/mybase/", basename: "/mybase/dashboard/" });
await workflowBuild({ page, port, basename: "/mybase/dashboard/" });
});

test("works when basename does not start with base", async ({ page }) => {
Expand Down

0 comments on commit 1185365

Please sign in to comment.