4
4
createHook,
5
5
executionAsyncId,
6
6
} = require ( 'async_hooks' ) ;
7
- const console = require ( 'console' ) ;
8
7
const {
9
8
codes : {
10
9
ERR_TEST_FAILURE ,
@@ -22,24 +21,24 @@ function createProcessEventHandler(eventName, rootTest) {
22
21
// Check if this error is coming from a test. If it is, fail the test.
23
22
const test = testResources . get ( executionAsyncId ( ) ) ;
24
23
25
- if ( test !== undefined ) {
26
- if ( test . finished ) {
27
- // If the test is already finished, report this as a top level
28
- // diagnostic since this is a malformed test.
29
- const msg = `Warning: Test "${ test . name } " generated asynchronous ` +
30
- 'activity after the test ended. This activity created the error ' +
31
- `"${ err } " and would have caused the test to fail, but instead ` +
32
- `triggered an ${ eventName } event.` ;
33
-
34
- rootTest . diagnostic ( msg ) ;
35
- return ;
36
- }
37
-
38
- test . fail ( new ERR_TEST_FAILURE ( err , eventName ) ) ;
39
- test . postRun ( ) ;
40
- } else {
41
- console . error ( err ) ;
24
+ if ( test === undefined ) {
25
+ throw err ;
26
+ }
27
+
28
+ if ( test . finished ) {
29
+ // If the test is already finished, report this as a top level
30
+ // diagnostic since this is a malformed test.
31
+ const msg = `Warning: Test "${ test . name } " generated asynchronous ` +
32
+ 'activity after the test ended. This activity created the error ' +
33
+ `"${ err } " and would have caused the test to fail, but instead ` +
34
+ `triggered an ${ eventName } event.` ;
35
+
36
+ rootTest . diagnostic ( msg ) ;
37
+ return ;
42
38
}
39
+
40
+ test . fail ( new ERR_TEST_FAILURE ( err , eventName ) ) ;
41
+ test . postRun ( ) ;
43
42
} ;
44
43
}
45
44
0 commit comments