Skip to content

Commit 2862601

Browse files
committed
Accept future object directly in reactRouterConfig test helper
1 parent 30f6c1d commit 2862601

11 files changed

+57
-53
lines changed

integration/client-data-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ test.describe("Client Data", () => {
149149
templateName,
150150
files: {
151151
"react-router.config.ts": reactRouterConfig({
152-
v8_splitRouteModules,
152+
future: { v8_splitRouteModules },
153153
}),
154154
"app/root.tsx": js`
155155
import { Form, Outlet, Scripts } from "react-router"

integration/helpers/vite.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,14 @@ export const reactRouterConfig = ({
2828
basename,
2929
prerender,
3030
appDirectory,
31-
v8_middleware,
32-
v8_splitRouteModules,
33-
v8_viteEnvironmentApi,
31+
future,
3432
routeDiscovery,
3533
}: {
3634
ssr?: boolean;
3735
basename?: string;
3836
prerender?: boolean | string[];
3937
appDirectory?: string;
40-
v8_middleware?: boolean;
41-
v8_splitRouteModules?: NonNullable<Config["future"]>["v8_splitRouteModules"];
42-
v8_viteEnvironmentApi?: boolean;
38+
future?: Partial<NonNullable<Config["future"]>>;
4339
routeDiscovery?: Config["routeDiscovery"];
4440
}) => {
4541
let config: Config = {
@@ -48,11 +44,7 @@ export const reactRouterConfig = ({
4844
prerender,
4945
appDirectory,
5046
routeDiscovery,
51-
future: {
52-
v8_middleware,
53-
v8_splitRouteModules,
54-
v8_viteEnvironmentApi,
55-
},
47+
future,
5648
};
5749

5850
return dedent`

integration/middleware-test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ test.describe("Middleware", () => {
4040
// ...existing code...
4141
"react-router.config.ts": reactRouterConfig({
4242
ssr: false,
43-
v8_middleware: true,
43+
future: { v8_middleware: true },
4444
}),
4545
"vite.config.ts": js`
4646
import { defineConfig } from "vite";
@@ -368,8 +368,7 @@ test.describe("Middleware", () => {
368368
files: {
369369
"react-router.config.ts": reactRouterConfig({
370370
ssr: false,
371-
v8_middleware: true,
372-
v8_splitRouteModules: true,
371+
future: { v8_middleware: true, v8_splitRouteModules: true },
373372
}),
374373
"vite.config.ts": js`
375374
import { defineConfig } from "vite";
@@ -466,7 +465,7 @@ test.describe("Middleware", () => {
466465
fixture = await createFixture({
467466
files: {
468467
"react-router.config.ts": reactRouterConfig({
469-
v8_middleware: true,
468+
future: { v8_middleware: true },
470469
}),
471470
"vite.config.ts": js`
472471
import { defineConfig } from "vite";
@@ -773,7 +772,7 @@ test.describe("Middleware", () => {
773772
let fixture = await createFixture({
774773
files: {
775774
"react-router.config.ts": reactRouterConfig({
776-
v8_middleware: true,
775+
future: { v8_middleware: true },
777776
}),
778777
"vite.config.ts": js`
779778
import { defineConfig } from "vite";
@@ -895,7 +894,7 @@ test.describe("Middleware", () => {
895894
let fixture = await createFixture({
896895
files: {
897896
"react-router.config.ts": reactRouterConfig({
898-
v8_middleware: true,
897+
future: { v8_middleware: true },
899898
}),
900899
"vite.config.ts": js`
901900
import { defineConfig } from "vite";
@@ -1060,8 +1059,7 @@ test.describe("Middleware", () => {
10601059
fixture = await createFixture({
10611060
files: {
10621061
"react-router.config.ts": reactRouterConfig({
1063-
v8_middleware: true,
1064-
v8_splitRouteModules: true,
1062+
future: { v8_middleware: true, v8_splitRouteModules: true },
10651063
}),
10661064
"vite.config.ts": js`
10671065
import { defineConfig } from "vite";
@@ -1156,7 +1154,9 @@ test.describe("Middleware", () => {
11561154
test.beforeAll(async () => {
11571155
fixture = await createFixture({
11581156
files: {
1159-
"react-router.config.ts": reactRouterConfig({ v8_middleware: true }),
1157+
"react-router.config.ts": reactRouterConfig({
1158+
future: { v8_middleware: true },
1159+
}),
11601160
"vite.config.ts": js`
11611161
import { defineConfig } from "vite";
11621162
import { reactRouter } from "@react-router/dev/vite";
@@ -1983,7 +1983,7 @@ test.describe("Middleware", () => {
19831983
{
19841984
files: {
19851985
"react-router.config.ts": reactRouterConfig({
1986-
v8_middleware: true,
1986+
future: { v8_middleware: true },
19871987
}),
19881988
"vite.config.ts": js`
19891989
import { defineConfig } from "vite";

integration/split-route-modules-test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ test.describe("Split route modules", async () => {
259259
port = await getPort();
260260
cwd = await createProject({
261261
"react-router.config.ts": reactRouterConfig({
262-
v8_splitRouteModules,
262+
future: { v8_splitRouteModules },
263263
}),
264264
"vite.config.js": await viteConfig.basic({ port }),
265265
...files,
@@ -366,7 +366,7 @@ test.describe("Split route modules", async () => {
366366
port = await getPort();
367367
cwd = await createProject({
368368
"react-router.config.ts": reactRouterConfig({
369-
v8_splitRouteModules,
369+
future: { v8_splitRouteModules },
370370
}),
371371
"vite.config.js": await viteConfig.basic({ port }),
372372
...files,
@@ -457,7 +457,7 @@ test.describe("Split route modules", async () => {
457457
port = await getPort();
458458
cwd = await createProject({
459459
"react-router.config.ts": reactRouterConfig({
460-
v8_splitRouteModules,
460+
future: { v8_splitRouteModules },
461461
}),
462462
"vite.config.js": await viteConfig.basic({ port }),
463463
// Make unsplittable routes valid so the build can pass
@@ -477,7 +477,7 @@ test.describe("Split route modules", async () => {
477477
port = await getPort();
478478
cwd = await createProject({
479479
"react-router.config.ts": reactRouterConfig({
480-
v8_splitRouteModules,
480+
future: { v8_splitRouteModules },
481481
}),
482482
"vite.config.js": await viteConfig.basic({ port }),
483483
"app/root.tsx": js`
@@ -505,7 +505,7 @@ test.describe("Split route modules", async () => {
505505
port = await getPort();
506506
cwd = await createProject({
507507
"react-router.config.ts": reactRouterConfig({
508-
v8_splitRouteModules,
508+
future: { v8_splitRouteModules },
509509
}),
510510
"vite.config.js": await viteConfig.basic({ port }),
511511
"app/root.tsx": js`
@@ -534,7 +534,7 @@ test.describe("Split route modules", async () => {
534534
port = await getPort();
535535
cwd = await createProject({
536536
"react-router.config.ts": reactRouterConfig({
537-
v8_splitRouteModules,
537+
future: { v8_splitRouteModules },
538538
}),
539539
"vite.config.js": await viteConfig.basic({ port }),
540540
...files,

integration/vite-build-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test.describe("Build", () => {
3838
ENV_VAR_FROM_DOTENV_FILE=true
3939
`,
4040
"react-router.config.ts": reactRouterConfig({
41-
v8_viteEnvironmentApi,
41+
future: { v8_viteEnvironmentApi },
4242
}),
4343
"vite.config.ts": js`
4444
import { defineConfig } from "vite";

integration/vite-cloudflare-test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ function getFiles({
1010
v8_viteEnvironmentApi: boolean;
1111
}): Files {
1212
return async ({ port }) => ({
13-
"react-router.config.ts": reactRouterConfig({ v8_viteEnvironmentApi }),
13+
"react-router.config.ts": reactRouterConfig({
14+
future: { v8_viteEnvironmentApi },
15+
}),
1416
"vite.config.ts": `
1517
import { reactRouter } from "@react-router/dev/vite";
1618
import { cloudflareDevProxy } from "@react-router/dev/vite/cloudflare";

integration/vite-css-test.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ test.describe("Vite CSS", () => {
216216
cwd = await createProject(
217217
{
218218
"react-router.config.ts": reactRouterConfig({
219-
v8_viteEnvironmentApi: templateName !== "vite-5-template",
219+
future: {
220+
v8_viteEnvironmentApi: templateName !== "vite-5-template",
221+
},
220222
}),
221223
"vite.config.ts": await viteConfig.basic({
222224
port,
@@ -258,7 +260,9 @@ test.describe("Vite CSS", () => {
258260
cwd = await createProject(
259261
{
260262
"react-router.config.ts": reactRouterConfig({
261-
v8_viteEnvironmentApi: templateName !== "vite-5-template",
263+
future: {
264+
v8_viteEnvironmentApi: templateName !== "vite-5-template",
265+
},
262266
basename: base,
263267
}),
264268
"vite.config.ts": await viteConfig.basic({
@@ -301,7 +305,9 @@ test.describe("Vite CSS", () => {
301305
cwd = await createProject(
302306
{
303307
"react-router.config.ts": reactRouterConfig({
304-
v8_viteEnvironmentApi: templateName !== "vite-5-template",
308+
future: {
309+
v8_viteEnvironmentApi: templateName !== "vite-5-template",
310+
},
305311
}),
306312
"vite.config.ts": await viteConfig.basic({
307313
port,
@@ -343,7 +349,9 @@ test.describe("Vite CSS", () => {
343349
cwd = await createProject(
344350
{
345351
"react-router.config.ts": reactRouterConfig({
346-
v8_viteEnvironmentApi: templateName !== "vite-5-template",
352+
future: {
353+
v8_viteEnvironmentApi: templateName !== "vite-5-template",
354+
},
347355
}),
348356
"vite.config.ts": await viteConfig.basic({
349357
port,
@@ -414,7 +422,9 @@ test.describe("Vite CSS", () => {
414422
cwd = await createProject(
415423
{
416424
"react-router.config.ts": reactRouterConfig({
417-
v8_viteEnvironmentApi: templateName !== "vite-5-template",
425+
future: {
426+
v8_viteEnvironmentApi: templateName !== "vite-5-template",
427+
},
418428
}),
419429
"vite.config.ts": await viteConfig.basic({
420430
port,

integration/vite-dev-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test.describe("Vite dev", () => {
3737
test.describe(`template: ${templateName} viteEnvironmentApi: ${v8_viteEnvironmentApi}`, () => {
3838
const files: Files = async ({ port }) => ({
3939
"react-router.config.ts": reactRouterConfig({
40-
v8_viteEnvironmentApi,
40+
future: { v8_viteEnvironmentApi },
4141
}),
4242
"vite.config.ts": await viteConfig.basic({
4343
port,

integration/vite-plugin-order-validation-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ test.describe("Vite plugin order validation", () => {
4343
});
4444
`,
4545
"react-router.config.ts": reactRouterConfig({
46-
v8_viteEnvironmentApi: true,
46+
future: { v8_viteEnvironmentApi: true },
4747
}),
4848
},
4949
"rsc-vite-framework",
@@ -72,7 +72,7 @@ test.describe("Vite plugin order validation", () => {
7272
});
7373
`,
7474
"react-router.config.ts": reactRouterConfig({
75-
v8_viteEnvironmentApi: true,
75+
future: { v8_viteEnvironmentApi: true },
7676
}),
7777
},
7878
"rsc-vite-framework",

integration/vite-preview-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ test.describe("Vite preview", () => {
322322
const files: Files = async ({ port }) => ({
323323
"react-router.config.ts": reactRouterConfig({
324324
ssr: false,
325-
v8_viteEnvironmentApi: true,
325+
future: { v8_viteEnvironmentApi: true },
326326
}),
327327
"vite.config.ts": await viteConfig.basic({
328328
port,

0 commit comments

Comments
 (0)