@@ -14,10 +14,6 @@ const cliMock = async (t, opts) => {
1414 const { Npm, outputs, logMocks, logs } = await loadMockNpm ( t , { ...opts , init : false } )
1515 const cli = t . mock ( '../../lib/cli.js' , {
1616 '../../lib/npm.js' : Npm ,
17- '../../lib/utils/unsupported.js' : {
18- checkForBrokenNode : ( ) => { } ,
19- checkForUnsupportedNode : ( ) => { } ,
20- } ,
2117 '../../lib/utils/exit-handler.js' : exitHandlerMock ,
2218 ...logMocks ,
2319 } )
@@ -175,3 +171,38 @@ t.test('load error calls error handler', async t => {
175171 await cli ( process )
176172 t . strictSame ( exitHandlerCalled ( ) , [ err ] )
177173} )
174+
175+ t . test ( 'known broken node version' , async t => {
176+ const errors = [ ]
177+ let exitCode
178+ const { cli } = await cliMock ( t , {
179+ globals : {
180+ 'console.error' : ( msg ) => errors . push ( msg ) ,
181+ 'process.version' : '6.0.0' ,
182+ 'process.exit' : e => exitCode = e ,
183+ } ,
184+ } )
185+ await cli ( process )
186+ t . match ( errors , [
187+ 'ERROR: npm is known not to run on Node.js 6.0.0' ,
188+ 'You\'ll need to upgrade to a newer Node.js version in order to use this' ,
189+ 'version of npm. You can find the latest version at https://nodejs.org/' ,
190+ ] )
191+ t . match ( exitCode , 1 )
192+ } )
193+
194+ t . test ( 'unsupported node version' , async t => {
195+ const errors = [ ]
196+ const { cli } = await cliMock ( t , {
197+ globals : {
198+ 'console.error' : ( msg ) => errors . push ( msg ) ,
199+ 'process.version' : '10.0.0' ,
200+ } ,
201+ } )
202+ await cli ( process )
203+ t . match ( errors , [
204+ 'npm does not support Node.js 10.0.0' ,
205+ 'You should probably upgrade to a newer version of node as we' ,
206+ 'can\'t make any promises that npm will work with this version.' ,
207+ ] )
208+ } )
0 commit comments