-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathvite-absolute-base-test.ts
40 lines (33 loc) · 1.15 KB
/
vite-absolute-base-test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { expect } from "@playwright/test";
import dedent from "dedent";
import type { Files } from "./helpers/vite.js";
import { test, viteConfig } from "./helpers/vite.js";
let files: Files = async ({ port }) => ({
"vite.config.ts": dedent`
import { reactRouter } from "@react-router/dev/vite";
export default {
base: "http://localhost:${port}/",
${await viteConfig.server({ port })}
plugins: [reactRouter()],
}
`,
"app/routes/_index.tsx": `
export default () => <h1 data-title>This should work</h1>;
`,
});
test("Vite absolute base / dev", async ({ page, dev }) => {
let { port } = await dev(files);
await page.goto(`http://localhost:${port}/`, {
waitUntil: "networkidle",
});
await expect(page.locator("[data-title]")).toHaveText("This should work");
expect(page.errors).toEqual([]);
});
test("Vite absolute base / build", async ({ page, reactRouterServe }) => {
let { port } = await reactRouterServe(files);
await page.goto(`http://localhost:${port}/`, {
waitUntil: "networkidle",
});
await expect(page.locator("[data-title]")).toHaveText("This should work");
expect(page.errors).toEqual([]);
});