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