@@ -59,29 +59,37 @@ test.beforeAll(async () => {
59
59
////////////////////////////////////////////////////////////////////////////
60
60
files : {
61
61
"app/routes/_index.tsx" : js `
62
- import { json } from "@remix-run/node";
63
- import { useLoaderData, Link } from "@remix-run/react";
64
-
65
- export function loader() {
66
- return json("pizza");
67
- }
62
+ import { myModule } from "my-module";
68
63
69
64
export default function Index() {
70
- let data = useLoaderData();
71
65
return (
72
66
<div>
73
- {data}
74
- <Link to="/burgers">Other Route</Link>
67
+ {myModule}
75
68
</div>
76
69
)
77
70
}
78
71
` ,
79
72
80
- "app/routes/burgers.tsx" : js `
81
- export default function Index() {
82
- return <div>cheeseburger</div>;
73
+ // NOTE: If "type": "module", is added, this test passes
74
+ "node_modules/my-module/package.json" : `
75
+ {
76
+ "name": "my-module",
77
+ "version": "1.0.0",
78
+ "main": "main.js",
79
+ "exports": {
80
+ ".": {
81
+ "require": "./main.js",
82
+ "import": "./main.esm.js"
83
+ }
84
+ }
83
85
}
84
86
` ,
87
+ "node_modules/my-module/main.esm.js" : js `
88
+ export const myModule = "hello from esm";
89
+ ` ,
90
+ "node_modules/my-module/main.js" : js `
91
+ exports.myModule = "hello from cjs";
92
+ ` ,
85
93
} ,
86
94
} ) ;
87
95
@@ -98,16 +106,16 @@ test.afterAll(() => {
98
106
// add a good description for what you expect Remix to do 👇🏽
99
107
////////////////////////////////////////////////////////////////////////////////
100
108
101
- test ( "[description of what you expect it to do] " , async ( { page } ) => {
109
+ test ( "Can be built and works " , async ( { page } ) => {
102
110
let app = new PlaywrightFixture ( appFixture , page ) ;
103
111
// You can test any request your app might get using `fixture`.
104
112
let response = await fixture . requestDocument ( "/" ) ;
105
- expect ( await response . text ( ) ) . toMatch ( "pizza " ) ;
113
+ expect ( await response . text ( ) ) . toMatch ( "hello from esm " ) ;
106
114
107
115
// If you need to test interactivity use the `app`
108
116
await app . goto ( "/" ) ;
109
- await app . clickLink ( "/burgers" ) ;
110
- await page . waitForSelector ( "text=cheeseburger" ) ;
117
+ // await app.clickLink("/burgers");
118
+ // await page.waitForSelector("text=cheeseburger");
111
119
112
120
// If you're not sure what's going on, you can "poke" the app, it'll
113
121
// automatically open up in your browser for 20 seconds, so be quick!
0 commit comments