@@ -67,6 +67,72 @@ describe("SuperTokens Example Basic tests", function () {
6767 headless : true ,
6868 } ) ;
6969 page = await browser . newPage ( ) ;
70+ page . on ( "console" , ( msg ) => {
71+ if ( msg . text ( ) . startsWith ( "com.supertokens" ) ) {
72+ console . log ( msg . text ( ) ) ;
73+ } else {
74+ console . log (
75+ `browserlog.console ${ JSON . stringify ( {
76+ t : new Date ( ) . toISOString ( ) ,
77+ message : msg . text ( ) ,
78+ pageurl : page . url ( ) ,
79+ } ) } `
80+ ) ;
81+ }
82+ } ) ;
83+
84+ page . on ( "request" , ( req ) => {
85+ console . log (
86+ `browserlog.network ${ JSON . stringify ( {
87+ t : new Date ( ) . toISOString ( ) ,
88+ message : `Requested: ${ req . method ( ) } ${ req . url ( ) } (${ req . postData ( ) } )` ,
89+ pageurl : page . url ( ) ,
90+ } ) } `
91+ ) ;
92+ } ) ;
93+ page . on ( "requestfinished" , async ( req ) => {
94+ if ( req . method ( ) === "OPTION" ) {
95+ return ;
96+ }
97+ const resp = await req . response ( ) ;
98+ let respText ;
99+ try {
100+ respText = req . url ( ) . startsWith ( TEST_APPLICATION_SERVER_BASE_URL )
101+ ? await resp . text ( )
102+ : "response omitted" ;
103+ } catch ( e ) {
104+ respText = "response loading failed " + e . message ;
105+ }
106+ console . log (
107+ `browserlog.network ${ JSON . stringify ( {
108+ t : new Date ( ) . toISOString ( ) ,
109+ message : `Request done: ${ req . method ( ) } ${ req . url ( ) } : ${ resp . status ( ) } ${ respText } ` ,
110+ pageurl : page . url ( ) ,
111+ } ) } `
112+ ) ;
113+ } ) ;
114+ page . on ( "requestfailed" , async ( req ) => {
115+ if ( req . method ( ) === "OPTION" ) {
116+ return ;
117+ }
118+ const resp = await req . response ( ) ;
119+ let respText ;
120+ try {
121+ respText = req . url ( ) . startsWith ( TEST_APPLICATION_SERVER_BASE_URL )
122+ ? await resp . text ( )
123+ : "response omitted" ;
124+ } catch ( e ) {
125+ respText = "response loading failed " + e . message ;
126+ }
127+ console . log (
128+ `browserlog.network ${ JSON . stringify ( {
129+ t : new Date ( ) . toISOString ( ) ,
130+ message : `Request failed: ${ req . method ( ) } ${ req . url ( ) } : ${ resp . status ( ) } ${ respText } ` ,
131+ pageurl : page . url ( ) ,
132+ } ) } `
133+ ) ;
134+ } ) ;
135+ return page ;
70136 } ) ;
71137
72138 after ( async function ( ) {
0 commit comments