File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -54,15 +54,19 @@ describe('Runtime tests', () => {
54
54
} else return msg ;
55
55
} ;
56
56
57
+ // file.ext -> file
57
58
const testName = path . basename ( testFile ) ;
59
+ // A promise that will resolve when JSDOM is done executing.
58
60
const testIsFinished = new FutureEvent ( ) ;
61
+ // A virtual console which will receive messages from JSDOM's `console.log`.
59
62
const virtualConsole = new VirtualConsole ( )
60
63
. on ( 'log' , ( msg ) => {
61
64
logs . push ( chalkMsg ( msg ) ) ;
62
65
if ( / T e s t s c o m p l e t e / i. test ( msg ) ) testIsFinished . ready ( allLogs ( ) ) ;
63
66
else if ( / T e s t s f a i l e d / i. test ( msg ) ) testIsFinished . cancel ( allLogs ( ) ) ;
64
67
} ) ;
65
68
69
+ // Load the generated test file for consumption by the JSDOM environment.
66
70
const testDocument = fs . readFileSync (
67
71
path . resolve (
68
72
__dirname ,
@@ -94,10 +98,13 @@ describe('Runtime tests', () => {
94
98
} ) ;
95
99
96
100
try {
101
+ // Wait for test to finish.
97
102
await testIsFinished ;
98
103
} catch ( e ) {
104
+ // If there was an error, print it.
99
105
fail ( `Failed test in suite ${ testName } : \n${ e } \n` ) ;
100
106
}
107
+ // Otherwise, everything passed.
101
108
console . log ( `Passed all tests in suite ${ testName } ` ) ;
102
109
} ) ;
103
110
}
You can’t perform that action at this time.
0 commit comments