@@ -72,24 +72,31 @@ describe('ESM: unsettled and rejected promises', { concurrency: !process.env.TES
72
72
} ) ;
73
73
74
74
it ( 'should exit for an unsettled TLA promise with warning' , async ( ) => {
75
- const { code, stderr, stdout } = await spawnPromisified ( execPath , [
75
+ const { code, stderr } = await spawnPromisified ( execPath , [
76
76
fixtures . path ( 'es-modules/tla/unresolved.mjs' ) ,
77
77
] ) ;
78
78
79
- assert . match ( stderr , / W a r n i n g : D e t e c t e d u n s e t t l e d t o p - l e v e l a w a i t a t .+ u n r e s o l v e d \. m j s : 1 / ) ;
79
+ assert . match ( stderr , / W a r n i n g : D e t e c t e d u n s e t t l e d t o p - l e v e l a w a i t a t .+ u n r e s o l v e d \. m j s : 5 / ) ;
80
80
assert . match ( stderr , / a w a i t n e w P r o m i s e / ) ;
81
- assert . strictEqual ( stdout , '' ) ;
81
+ assert . strictEqual ( code , 13 ) ;
82
+ } ) ;
83
+
84
+ it ( 'the process exit event should provide the correct code for an unsettled TLA promise' , async ( ) => {
85
+ const { code, stdout } = await spawnPromisified ( execPath , [
86
+ fixtures . path ( 'es-modules/tla/unresolved.mjs' ) ,
87
+ ] ) ;
88
+
89
+ assert . strictEqual ( stdout , 'the exit listener received code: 13\n' ) ;
82
90
assert . strictEqual ( code , 13 ) ;
83
91
} ) ;
84
92
85
93
it ( 'should exit for an unsettled TLA promise without warning' , async ( ) => {
86
- const { code, stderr, stdout } = await spawnPromisified ( execPath , [
94
+ const { code, stderr } = await spawnPromisified ( execPath , [
87
95
'--no-warnings' ,
88
96
fixtures . path ( 'es-modules/tla/unresolved.mjs' ) ,
89
97
] ) ;
90
98
91
99
assert . strictEqual ( stderr , '' ) ;
92
- assert . strictEqual ( stdout , '' ) ;
93
100
assert . strictEqual ( code , 13 ) ;
94
101
} ) ;
95
102
@@ -105,13 +112,22 @@ describe('ESM: unsettled and rejected promises', { concurrency: !process.env.TES
105
112
} ) ;
106
113
107
114
it ( 'should exit for an unsettled TLA promise and respect explicit exit code via stdin' , async ( ) => {
108
- const { code, stderr, stdout } = await spawnPromisified ( execPath , [
115
+ const { code, stderr } = await spawnPromisified ( execPath , [
109
116
'--no-warnings' ,
110
117
fixtures . path ( 'es-modules/tla/unresolved-withexitcode.mjs' ) ,
111
118
] ) ;
112
119
113
120
assert . strictEqual ( stderr , '' ) ;
114
- assert . strictEqual ( stdout , '' ) ;
121
+ assert . strictEqual ( code , 42 ) ;
122
+ } ) ;
123
+
124
+ it ( 'should exit for an unsettled TLA promise and respect explicit exit code in process exit event' , async ( ) => {
125
+ const { code, stdout } = await spawnPromisified ( execPath , [
126
+ '--no-warnings' ,
127
+ fixtures . path ( 'es-modules/tla/unresolved-withexitcode.mjs' ) ,
128
+ ] ) ;
129
+
130
+ assert . strictEqual ( stdout , 'the exit listener received code: 42\n' ) ;
115
131
assert . strictEqual ( code , 42 ) ;
116
132
} ) ;
117
133
0 commit comments