@@ -15,7 +15,7 @@ describe('--print with a promise', { concurrency: true }, () => {
15
15
code : 0 ,
16
16
signal : null ,
17
17
stderr : '' ,
18
- stdout : 'Promise { 42 } \n' ,
18
+ stdout : '42 \n' ,
19
19
} ) ;
20
20
} ) ;
21
21
@@ -29,7 +29,7 @@ describe('--print with a promise', { concurrency: true }, () => {
29
29
code : 0 ,
30
30
signal : null ,
31
31
stderr : '' ,
32
- stdout : 'Promise { <pending> } \n' ,
32
+ stdout : '42 \n' ,
33
33
} ) ;
34
34
} ) ;
35
35
@@ -43,7 +43,7 @@ describe('--print with a promise', { concurrency: true }, () => {
43
43
code : 0 ,
44
44
signal : null ,
45
45
stderr : '' ,
46
- stdout : 'Promise { <pending> }\n ' ,
46
+ stdout : '' ,
47
47
} ) ;
48
48
} ) ;
49
49
@@ -57,11 +57,11 @@ describe('--print with a promise', { concurrency: true }, () => {
57
57
code : 0 ,
58
58
signal : null ,
59
59
stderr : '' ,
60
- stdout : 'Promise { <pending> }\n ' ,
60
+ stdout : '' ,
61
61
} ) ;
62
62
} ) ;
63
63
64
- it ( 'should handle rejected promises' , async ( ) => {
64
+ it ( 'should handle rejected promises with unhandled-rejections=none ' , async ( ) => {
65
65
const result = await spawnPromisified ( execPath , [
66
66
'--unhandled-rejections=none' ,
67
67
'--print' ,
@@ -72,11 +72,11 @@ describe('--print with a promise', { concurrency: true }, () => {
72
72
code : 0 ,
73
73
signal : null ,
74
74
stderr : '' ,
75
- stdout : 'Promise { <rejected> 1 }\n ' ,
75
+ stdout : '' ,
76
76
} ) ;
77
77
} ) ;
78
78
79
- it ( 'should handle promises that reject after one tick' , async ( ) => {
79
+ it ( 'should handle promises that reject after one tick with unhandled-rejections=none ' , async ( ) => {
80
80
const result = await spawnPromisified ( execPath , [
81
81
'--unhandled-rejections=none' ,
82
82
'--print' ,
@@ -87,7 +87,32 @@ describe('--print with a promise', { concurrency: true }, () => {
87
87
code : 0 ,
88
88
signal : null ,
89
89
stderr : '' ,
90
- stdout : 'Promise { <pending> }\n ' ,
90
+ stdout : '' ,
91
91
} ) ;
92
92
} ) ;
93
+
94
+ it ( 'should error with unhandled rejected promises' , async ( ) => {
95
+ const result = await spawnPromisified ( execPath , [
96
+ '--print' ,
97
+ 'Promise.reject(1)' ,
98
+ ] ) ;
99
+
100
+ assert . strictEqual ( result . code , 1 ) ;
101
+ assert . strictEqual ( result . signal , null ) ;
102
+ assert . strictEqual ( result . stdout , '' ) ;
103
+ assert . ok ( result . stderr . includes ( 'ERR_UNHANDLED_REJECTION' ) , 'Not found ERR_UNHANDLED_REJECTION' ) ;
104
+ } ) ;
105
+
106
+ it ( 'should error when throw inside fn' , async ( ) => {
107
+ const result = await spawnPromisified ( execPath , [
108
+ '--print' ,
109
+ 'Promise.resolve().then(()=>{throw new Error(10)})' ,
110
+ ] ) ;
111
+
112
+ assert . strictEqual ( result . code , 1 ) ;
113
+ assert . strictEqual ( result . signal , null ) ;
114
+ assert . strictEqual ( result . stdout , '' ) ;
115
+ assert . ok ( result . stderr . includes ( 'throw new Error(10)' ) , `Found: ${ result . stderr } ` ) ;
116
+ assert . ok ( result . stderr . includes ( 'Error: 10' ) , `Found: ${ result . stderr } ` ) ;
117
+ } ) ;
93
118
} ) ;
0 commit comments