7
7
createFixture ,
8
8
js ,
9
9
} from "./helpers/create-fixture.js" ;
10
+ import { build , createProject , reactRouterConfig } from "./helpers/vite.js" ;
10
11
11
12
let fixture : Fixture ;
12
13
let appFixture : AppFixture ;
@@ -34,13 +35,13 @@ let appFixture: AppFixture;
34
35
// Now try running this test:
35
36
//
36
37
// ```
37
- // pnpm bug-report-test
38
+ // pnpm test:integration integration/ bug-report-test.ts
38
39
// ```
39
40
//
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 :
41
42
//
42
43
// ```
43
- // pnpm bug-report-test --watch
44
+ // pnpm test:integration integration/ bug-report-test.ts --ui
44
45
// ```
45
46
////////////////////////////////////////////////////////////////////////////////
46
47
@@ -51,68 +52,28 @@ test.beforeEach(async ({ context }) => {
51
52
} ) ;
52
53
} ) ;
53
54
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
-
95
55
////////////////////////////////////////////////////////////////////////////////
96
56
// 💿 Almost done, now write your failing test case(s) down here Make sure to
97
57
// add a good description for what you expect Remix to do 👇🏽
98
58
////////////////////////////////////////////////////////////////////////////////
99
59
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 ( "" ) ;
116
77
} ) ;
117
78
118
79
////////////////////////////////////////////////////////////////////////////////
0 commit comments