Commit 102c2fd 1 parent 6c323d5 commit 102c2fd Copy full SHA for 102c2fd
File tree 2 files changed +24
-4
lines changed
playground/html/__tests__
2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,6 @@ kbd {
165
165
`
166
166
167
167
// Error Template
168
- let template : HTMLElement
169
168
const createTemplate = ( ) =>
170
169
h (
171
170
'div' ,
@@ -214,9 +213,7 @@ export class ErrorOverlay extends HTMLElement {
214
213
constructor ( err : ErrorPayload [ 'err' ] , links = true ) {
215
214
super ( )
216
215
this . root = this . attachShadow ( { mode : 'open' } )
217
-
218
- template ??= createTemplate ( )
219
- this . root . appendChild ( template )
216
+ this . root . appendChild ( createTemplate ( ) )
220
217
221
218
codeframeRE . lastIndex = 0
222
219
const hasFrame = err . frame && codeframeRE . test ( err . frame )
Original file line number Diff line number Diff line change @@ -274,6 +274,29 @@ describe.runIf(isServe)('invalid', () => {
274
274
expect ( isVisbleOverlay ) . toBeFalsy ( )
275
275
} )
276
276
277
+ test ( 'stack is updated' , async ( ) => {
278
+ await page . goto ( viteTestUrl + '/invalid.html' )
279
+
280
+ const errorOverlay = await page . waitForSelector ( 'vite-error-overlay' )
281
+ const hiddenPromise = errorOverlay . waitForElementState ( 'hidden' )
282
+ await page . keyboard . press ( 'Escape' )
283
+ await hiddenPromise
284
+
285
+ viteServer . hot . send ( {
286
+ type : 'error' ,
287
+ err : {
288
+ message : 'someError' ,
289
+ stack : [
290
+ 'Error: someError' ,
291
+ ' at someMethod (/some/file.ts:1:2)' ,
292
+ ] . join ( '\n' ) ,
293
+ } ,
294
+ } )
295
+ const newErrorOverlay = await page . waitForSelector ( 'vite-error-overlay' )
296
+ const stack = await newErrorOverlay . $$eval ( '.stack' , ( m ) => m [ 0 ] . innerHTML )
297
+ expect ( stack ) . toMatch ( / ^ E r r o r : s o m e E r r o r / )
298
+ } )
299
+
277
300
test ( 'should reload when fixed' , async ( ) => {
278
301
await page . goto ( viteTestUrl + '/invalid.html' )
279
302
await editFile ( 'invalid.html' , ( content ) => {
You can’t perform that action at this time.
0 commit comments