Skip to content

Commit c06be20

Browse files
committed
Add prerender SPA mode bug report test
1 parent 6c27453 commit c06be20

File tree

1 file changed

+21
-60
lines changed

1 file changed

+21
-60
lines changed

integration/bug-report-test.ts

+21-60
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
createFixture,
88
js,
99
} from "./helpers/create-fixture.js";
10+
import { build, createProject, reactRouterConfig } from "./helpers/vite.js";
1011

1112
let fixture: Fixture;
1213
let appFixture: AppFixture;
@@ -34,13 +35,13 @@ let appFixture: AppFixture;
3435
// Now try running this test:
3536
//
3637
// ```
37-
// pnpm bug-report-test
38+
// pnpm test:integration integration/bug-report-test.ts
3839
// ```
3940
//
40-
// You can add `--watch` to the end to have it re-run on file changes:
41+
// You can add `--ui` to the end to explore, watch, and debug the test:
4142
//
4243
// ```
43-
// pnpm bug-report-test --watch
44+
// pnpm test:integration integration/bug-report-test.ts --ui
4445
// ```
4546
////////////////////////////////////////////////////////////////////////////////
4647

@@ -51,68 +52,28 @@ test.beforeEach(async ({ context }) => {
5152
});
5253
});
5354

54-
test.beforeAll(async () => {
55-
fixture = await createFixture({
56-
////////////////////////////////////////////////////////////////////////////
57-
// 💿 Next, add files to this object, just like files in a real app,
58-
// `createFixture` will make an app and run your tests against it.
59-
////////////////////////////////////////////////////////////////////////////
60-
files: {
61-
"app/routes/_index.tsx": js`
62-
import { useLoaderData, Link } from "react-router";
63-
64-
export function loader() {
65-
return "pizza";
66-
}
67-
68-
export default function Index() {
69-
let data = useLoaderData();
70-
return (
71-
<div>
72-
{data}
73-
<Link to="/burgers">Other Route</Link>
74-
</div>
75-
)
76-
}
77-
`,
78-
79-
"app/routes/burgers.tsx": js`
80-
export default function Index() {
81-
return <div>cheeseburger</div>;
82-
}
83-
`,
84-
},
85-
});
86-
87-
// This creates an interactive app using playwright.
88-
appFixture = await createAppFixture(fixture);
89-
});
90-
91-
test.afterAll(() => {
92-
appFixture.close();
93-
});
94-
9555
////////////////////////////////////////////////////////////////////////////////
9656
// 💿 Almost done, now write your failing test case(s) down here Make sure to
9757
// add a good description for what you expect Remix to do 👇🏽
9858
////////////////////////////////////////////////////////////////////////////////
9959

100-
test("[description of what you expect it to do]", async ({ page }) => {
101-
let app = new PlaywrightFixture(appFixture, page);
102-
// You can test any request your app might get using `fixture`.
103-
let response = await fixture.requestDocument("/");
104-
expect(await response.text()).toMatch("pizza");
105-
106-
// If you need to test interactivity use the `app`
107-
await app.goto("/");
108-
await app.clickLink("/burgers");
109-
await page.waitForSelector("text=cheeseburger");
110-
111-
// If you're not sure what's going on, you can "poke" the app, it'll
112-
// automatically open up in your browser for 20 seconds, so be quick!
113-
// await app.poke(20);
114-
115-
// Go check out the other tests to see what else you can do.
60+
test("allows route loader for pre-rendered routes in SPA mode", async () => {
61+
const cwd = await createProject({
62+
"react-router.config.ts": reactRouterConfig({
63+
prerender: true,
64+
ssr: false,
65+
}),
66+
"app/routes/invalid-exports.tsx": String.raw`
67+
// Valid exports
68+
export function loader() {}
69+
export function clientLoader() {}
70+
export function clientAction() {}
71+
export default function Component() {}
72+
`,
73+
});
74+
const result = build({ cwd });
75+
const stderr = result.stderr.toString("utf8");
76+
expect(stderr).toBe("");
11677
});
11778

11879
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)