@@ -22,58 +22,6 @@ function debug(...args: unknown[]) {
2222 }
2323}
2424
25- async function tryCall < T > (
26- fn : ( ) => Promise < T > ,
27- ) : Promise < T | false | undefined > {
28- try {
29- return await fn ( )
30- }
31- catch ( err : any ) {
32- const now = Date . now ( )
33- // try for 30 seconds
34- const canTry = ! reloadStart || now - Number ( reloadStart ) < 30_000
35- const errorStack = ( ( ) => {
36- if ( ! err ) {
37- return null
38- }
39- return err . stack ?. includes ( err . message )
40- ? err . stack
41- : `${ err . message } \n${ err . stack } `
42- } ) ( )
43- debug (
44- 'failed to resolve runner' ,
45- 'trying again:' ,
46- canTry ,
47- 'time is' ,
48- now ,
49- 'reloadStart is' ,
50- reloadStart ,
51- ':\n' ,
52- errorStack ,
53- )
54- if ( ! canTry ) {
55- const error = serializeError (
56- new Error ( 'Vitest failed to load its runner after 30 seconds.' ) ,
57- )
58- error . cause = serializeError ( err )
59-
60- await client . rpc . onUnhandledError ( error , 'Preload Error' )
61- return false
62- }
63-
64- if ( ! reloadStart ) {
65- const newUrl = new URL ( location . href )
66- newUrl . searchParams . set ( '__reloadStart' , now . toString ( ) )
67- debug ( 'set the new url because reload start is not set to' , newUrl )
68- location . href = newUrl . toString ( )
69- }
70- else {
71- debug ( 'reload the iframe because reload start is set' , location . href )
72- location . reload ( )
73- }
74- }
75- }
76-
7725async function prepareTestEnvironment ( files : string [ ] ) {
7826 debug ( 'trying to resolve runner' , `${ reloadStart } ` )
7927 const config = getConfig ( )
@@ -142,7 +90,7 @@ async function runTests(files: string[]) {
14290
14391 // if importing /@id / failed, we reload the page waiting until Vite prebundles it
14492 try {
145- preparedData = await tryCall ( ( ) => prepareTestEnvironment ( files ) )
93+ preparedData = await prepareTestEnvironment ( files )
14694 }
14795 catch ( error ) {
14896 debug ( 'data cannot be loaded because it threw an error' )
@@ -151,13 +99,6 @@ async function runTests(files: string[]) {
15199 return
152100 }
153101
154- // cannot load data, finish the test
155- if ( preparedData === false ) {
156- debug ( 'data cannot be loaded, finishing the test' )
157- done ( files )
158- return
159- }
160-
161102 // page is reloading
162103 if ( ! preparedData ) {
163104 debug ( 'page is reloading, waiting for the next run' )
0 commit comments