Skip to content

Commit

Permalink
chore: adds devEngines global install test
Browse files Browse the repository at this point in the history
  • Loading branch information
reggi committed Oct 3, 2024
1 parent 4fedafb commit e59797f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tap-snapshots/test/lib/commands/install.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`test/lib/commands/install.js TAP devEngines should not utilize devEngines if global install > must match snapshot 1`] = `
silly config load:file:{CWD}/npmrc
silly config load:file:{CWD}/home/.npmrc
silly config load:file:{CWD}/global/etc/npmrc
verbose title npm
verbose argv "--fetch-retries" "0" "--cache" "{CWD}/cache" "--loglevel" "silly" "--color" "false" "--global" "true"
verbose logfile logs-max:10 dir:{CWD}/cache/_logs/{DATE}-
verbose logfile {CWD}/cache/_logs/{DATE}-debug-0.log
silly logfile done cleaning log files
silly packumentCache heap:{heap} maxSize:{maxSize} maxEntrySize:{maxEntrySize}
silly idealTree buildDeps
silly placeDep ROOT alpha@ OK for: want: file:../../prefix
silly reify moves {}
silly ADD node_modules/alpha
added 1 package in {TIME}
`

exports[`test/lib/commands/install.js TAP devEngines should not utilize engines in root if devEngines is provided > must match snapshot 1`] = `
silly config load:file:{CWD}/npmrc
silly config load:file:{CWD}/prefix/.npmrc
Expand Down
29 changes: 29 additions & 0 deletions test/lib/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,4 +687,33 @@ t.test('devEngines', async t => {
t.ok(output.includes('EBADENGINE'))
t.ok(!output.includes('EBADDEVENGINES'))
})

t.test('should not utilize devEngines if global install', async t => {
const { npm, joinedFullOutput } = await loadMockNpm(t, {
...mockArguments,
config: {
global: true,
},
prefixDir: {
'package.json': JSON.stringify({
name: 'alpha',
bin: {
alpha: 'index.js',
},
devEngines: {
runtime: {
name: 'node',
version: '0.0.1',
},
},
}),
'index.js': 'console.log("this is alpha index")',
},
})
await npm.exec('install', ['.'])
const output = joinedFullOutput()
t.matchSnapshot(output)
t.ok(!output.includes('EBADENGINE'))
t.ok(!output.includes('EBADDEVENGINES'))
})
})

0 comments on commit e59797f

Please sign in to comment.