@@ -3,6 +3,8 @@ import { FileRef, nextTestSetup } from 'e2e-utils'
3
3
import { outdent } from 'outdent'
4
4
import path from 'path'
5
5
6
+ const isRspack = process . env . NEXT_RSPACK !== undefined
7
+
6
8
describe ( 'ReactRefreshLogBox _app _document' , ( ) => {
7
9
const { isTurbopack, next } = nextTestSetup ( {
8
10
files : new FileRef ( path . join ( __dirname , 'fixtures' , 'default-template' ) ) ,
@@ -120,6 +122,39 @@ describe('ReactRefreshLogBox _app _document', () => {
120
122
"stack": [],
121
123
}
122
124
` )
125
+ } else if ( isRspack ) {
126
+ await expect ( { browser, next } ) . toDisplayRedbox ( `
127
+ {
128
+ "count": 1,
129
+ "description": " × Module build failed:",
130
+ "environmentLabel": null,
131
+ "label": "Build Error",
132
+ "source": "./pages/_app.js
133
+ × Module build failed:
134
+ ├─▶ ×
135
+ │ │ x Expression expected
136
+ │ │ ,-[<FIXME-project-root>/pages/_app.js:2:1]
137
+ │ │ 1 | function MyApp({ Component, pageProps }) {
138
+ │ │ 2 | return <<Component {...pageProps} />;
139
+ │ │ : ^
140
+ │ │ 3 | }
141
+ │ │ 4 | export default MyApp
142
+ │ │ \`----
143
+ │ │
144
+ │ │ x Expression expected
145
+ │ │ ,-[<FIXME-project-root>/pages/_app.js:2:1]
146
+ │ │ 1 | function MyApp({ Component, pageProps }) {
147
+ │ │ 2 | return <<Component {...pageProps} />;
148
+ │ │ : ^^^^^^^^^
149
+ │ │ 3 | }
150
+ │ │ 4 | export default MyApp
151
+ │ │ \`----
152
+ │ │
153
+ │
154
+ ╰─▶ Syntax Error",
155
+ "stack": [],
156
+ }
157
+ ` )
123
158
} else {
124
159
await expect ( browser ) . toDisplayRedbox ( `
125
160
{
@@ -211,6 +246,32 @@ describe('ReactRefreshLogBox _app _document', () => {
211
246
"stack": [],
212
247
}
213
248
` )
249
+ } else if ( isRspack ) {
250
+ await expect ( { browser, next } ) . toDisplayRedbox ( `
251
+ {
252
+ "count": 1,
253
+ "description": " × Module build failed:",
254
+ "environmentLabel": null,
255
+ "label": "Build Error",
256
+ "source": "./pages/_document.js
257
+ × Module build failed:
258
+ ├─▶ ×
259
+ │ │ x Unexpected token \`{\`. Expected identifier, string literal, numeric literal or [ for the computed key
260
+ │ │ ,-[<FIXME-project-root>/pages/_document.js:3:1]
261
+ │ │ 1 | import Document, { Html, Head, Main, NextScript } from 'next/document'
262
+ │ │ 2 |
263
+ │ │ 3 | class MyDocument extends Document {{
264
+ │ │ : ^
265
+ │ │ 4 | static async getInitialProps(ctx) {
266
+ │ │ 5 | const initialProps = await Document.getInitialProps(ctx)
267
+ │ │ 6 | return { ...initialProps }
268
+ │ │ \`----
269
+ │ │
270
+ │
271
+ ╰─▶ Syntax Error",
272
+ "stack": [],
273
+ }
274
+ ` )
214
275
} else {
215
276
await expect ( browser ) . toDisplayRedbox ( `
216
277
{
0 commit comments