@@ -11,6 +11,41 @@ export async function gotoVoyagerPage(
11
11
page : Page ,
12
12
searchParams ?: VoyagerURLParams ,
13
13
) {
14
+ // Add error/console checkers before we open Voyager page to track errors during loading
15
+ page . on ( 'pageerror' , ( error ) => {
16
+ throw error ;
17
+ } ) ;
18
+ page . on ( 'requestfailed' , ( request ) => {
19
+ throw new Error ( request . url ( ) + ' ' + request . failure ( ) ?. errorText ) ;
20
+ } ) ;
21
+ page . on ( 'response' , ( response ) => {
22
+ if ( response . status ( ) != 200 ) {
23
+ throw new Error (
24
+ `${ response . url ( ) } : ${ response . status ( ) } ${ response . statusText ( ) } ` ,
25
+ ) ;
26
+ }
27
+ } ) ;
28
+ page . on ( 'console' , ( message ) => {
29
+ const type = message . type ( ) ;
30
+ const text = message . text ( ) ;
31
+ const { url, lineNumber } = message . location ( ) ;
32
+ const location = `${ url } :${ lineNumber } ` ;
33
+
34
+ switch ( type ) {
35
+ case 'timeEnd' :
36
+ if ( text . startsWith ( 'graphql-voyager: Rendering SVG:' ) ) {
37
+ return ;
38
+ }
39
+ break ;
40
+ case 'log' :
41
+ if ( text . startsWith ( 'graphql-voyager: SVG cached' ) ) {
42
+ return ;
43
+ }
44
+ break ;
45
+ }
46
+ throw new Error ( `[${ type . toUpperCase ( ) } ] at '${ location } ': ${ text } ` ) ;
47
+ } ) ;
48
+
14
49
const search = new URLSearchParams ( ) ;
15
50
if ( searchParams ?. url != null ) {
16
51
search . append ( 'url' , searchParams . url ) ;
@@ -56,40 +91,6 @@ class PlaywrightVoyagerPage {
56
91
} ) ;
57
92
58
93
this . changeSchemaDialog = new PlaywrightChangeSchemaDialog ( page ) ;
59
-
60
- page . on ( 'pageerror' , ( error ) => {
61
- throw error ;
62
- } ) ;
63
- page . on ( 'requestfailed' , ( request ) => {
64
- throw new Error ( request . url ( ) + ' ' + request . failure ( ) ?. errorText ) ;
65
- } ) ;
66
- page . on ( 'response' , ( response ) => {
67
- if ( response . status ( ) != 200 ) {
68
- throw new Error (
69
- `${ response . url ( ) } : ${ response . status ( ) } ${ response . statusText ( ) } ` ,
70
- ) ;
71
- }
72
- } ) ;
73
- page . on ( 'console' , ( message ) => {
74
- const type = message . type ( ) ;
75
- const text = message . text ( ) ;
76
- const { url, lineNumber } = message . location ( ) ;
77
- const location = `${ url } :${ lineNumber } ` ;
78
-
79
- switch ( type ) {
80
- case 'timeEnd' :
81
- if ( text . startsWith ( 'graphql-voyager: Rendering SVG:' ) ) {
82
- return ;
83
- }
84
- break ;
85
- case 'log' :
86
- if ( text . startsWith ( 'graphql-voyager: SVG cached' ) ) {
87
- return ;
88
- }
89
- break ;
90
- }
91
- throw new Error ( `[${ type . toUpperCase ( ) } ] at '${ location } ': ${ text } ` ) ;
92
- } ) ;
93
94
}
94
95
95
96
async waitForGraphToBeLoaded ( ) : Promise < void > {
0 commit comments