@@ -16,10 +16,6 @@ const cliMock = async (t, mocks) => {
1616 const cli = t . mock ( '../../lib/cli.js' , {
1717 '../../lib/npm.js' : Npm ,
1818 '../../lib/utils/update-notifier.js' : async ( ) => null ,
19- '../../lib/utils/unsupported.js' : {
20- checkForBrokenNode : ( ) => { } ,
21- checkForUnsupportedNode : ( ) => { } ,
22- } ,
2319 '../../lib/utils/exit-handler.js' : exitHandlerMock ,
2420 ...logMocks ,
2521 } )
@@ -162,3 +158,36 @@ t.test('load error calls error handler', async t => {
162158 await cli ( process )
163159 t . strictSame ( exitHandlerCalled ( ) , [ err ] )
164160} )
161+
162+ t . test ( 'known broken node version' , async t => {
163+ const errors = [ ]
164+ let exitCode
165+ mockGlobals ( t , {
166+ 'console.error' : ( msg ) => errors . push ( msg ) ,
167+ 'process.version' : '6.0.0' ,
168+ 'process.exit' : e => exitCode = e ,
169+ } )
170+ const { cli } = await cliMock ( t )
171+ await cli ( process )
172+ t . match ( errors , [
173+ 'ERROR: npm is known not to run on Node.js 6.0.0' ,
174+ 'You\'ll need to upgrade to a newer Node.js version in order to use this' ,
175+ 'version of npm. You can find the latest version at https://nodejs.org/' ,
176+ ] )
177+ t . match ( exitCode , 1 )
178+ } )
179+
180+ t . test ( 'unsupported node version' , async t => {
181+ const errors = [ ]
182+ mockGlobals ( t , {
183+ 'console.error' : ( msg ) => errors . push ( msg ) ,
184+ 'process.version' : '10.0.0' ,
185+ } )
186+ const { cli } = await cliMock ( t )
187+ await cli ( process )
188+ t . match ( errors , [
189+ 'npm does not support Node.js 10.0.0' ,
190+ 'You should probably upgrade to a newer version of node as we' ,
191+ 'can\'t make any promises that npm will work with this version.' ,
192+ ] )
193+ } )
0 commit comments