@@ -10,6 +10,10 @@ const Import2 = fixtures.path('/es-modules/es-note-promiserej-import-2.cjs');
10
10
const Import3 = fixtures . path ( '/es-modules/es-note-unexpected-import-3.cjs' ) ;
11
11
const Import4 = fixtures . path ( '/es-modules/es-note-unexpected-import-4.cjs' ) ;
12
12
const Import5 = fixtures . path ( '/es-modules/es-note-unexpected-import-5.cjs' ) ;
13
+ const Error1 = fixtures . path ( '/es-modules/es-note-error-1.mjs' ) ;
14
+ const Error2 = fixtures . path ( '/es-modules/es-note-error-2.mjs' ) ;
15
+ const Error3 = fixtures . path ( '/es-modules/es-note-error-3.mjs' ) ;
16
+ const Error4 = fixtures . path ( '/es-modules/es-note-error-4.mjs' ) ;
13
17
14
18
// Expect note to be included in the error output
15
19
const expectedNote = 'To load an ES module, ' +
@@ -106,3 +110,55 @@ pImport5.on('close', mustCall((code) => {
106
110
assert . ok ( ! pImport5Stderr . includes ( expectedNote ) ,
107
111
`${ expectedNote } must not be included in ${ pImport5Stderr } ` ) ;
108
112
} ) ) ;
113
+
114
+ const pError1 = spawn ( process . execPath , [ Error1 ] ) ;
115
+ let pError1Stderr = '' ;
116
+ pError1 . stderr . setEncoding ( 'utf8' ) ;
117
+ pError1 . stderr . on ( 'data' , ( data ) => {
118
+ pError1Stderr += data ;
119
+ } ) ;
120
+ pError1 . on ( 'close' , mustCall ( ( code ) => {
121
+ assert . strictEqual ( code , expectedCode ) ;
122
+ assert . ok ( pError1Stderr . includes ( 'Error: some error' ) ) ;
123
+ assert . ok ( ! pError1Stderr . includes ( expectedNote ) ,
124
+ `${ expectedNote } must not be included in ${ pError1Stderr } ` ) ;
125
+ } ) ) ;
126
+
127
+ const pError2 = spawn ( process . execPath , [ Error2 ] ) ;
128
+ let pError2Stderr = '' ;
129
+ pError2 . stderr . setEncoding ( 'utf8' ) ;
130
+ pError2 . stderr . on ( 'data' , ( data ) => {
131
+ pError2Stderr += data ;
132
+ } ) ;
133
+ pError2 . on ( 'close' , mustCall ( ( code ) => {
134
+ assert . strictEqual ( code , expectedCode ) ;
135
+ assert . ok ( pError2Stderr . includes ( 'string' ) ) ;
136
+ assert . ok ( ! pError2Stderr . includes ( expectedNote ) ,
137
+ `${ expectedNote } must not be included in ${ pError2Stderr } ` ) ;
138
+ } ) ) ;
139
+
140
+ const pError3 = spawn ( process . execPath , [ Error3 ] ) ;
141
+ let pError3Stderr = '' ;
142
+ pError3 . stderr . setEncoding ( 'utf8' ) ;
143
+ pError3 . stderr . on ( 'data' , ( data ) => {
144
+ pError3Stderr += data ;
145
+ } ) ;
146
+ pError3 . on ( 'close' , mustCall ( ( code ) => {
147
+ assert . strictEqual ( code , expectedCode ) ;
148
+ assert . ok ( pError3Stderr . includes ( 'null' ) ) ;
149
+ assert . ok ( ! pError3Stderr . includes ( expectedNote ) ,
150
+ `${ expectedNote } must not be included in ${ pError3Stderr } ` ) ;
151
+ } ) ) ;
152
+
153
+ const pError4 = spawn ( process . execPath , [ Error4 ] ) ;
154
+ let pError4Stderr = '' ;
155
+ pError4 . stderr . setEncoding ( 'utf8' ) ;
156
+ pError4 . stderr . on ( 'data' , ( data ) => {
157
+ pError4Stderr += data ;
158
+ } ) ;
159
+ pError4 . on ( 'close' , mustCall ( ( code ) => {
160
+ assert . strictEqual ( code , expectedCode ) ;
161
+ assert . ok ( pError4Stderr . includes ( 'undefined' ) ) ;
162
+ assert . ok ( ! pError4Stderr . includes ( expectedNote ) ,
163
+ `${ expectedNote } must not be included in ${ pError4Stderr } ` ) ;
164
+ } ) ) ;
0 commit comments