1var fs = require('fs') 2var path = require('path') 3 4var mkdirp = require('mkdirp') 5var test = require('tap').test 6 7var common = require('../common-tap.js') 8var pkg = common.pkg 9var local = path.join(pkg, 'package') 10 11var EXEC_OPTS = { cwd: pkg } 12 13var json = { 14 name: '@scope/package', 15 version: '0.0.0', 16 peerDependencies: { 17 underscore: '*' 18 } 19} 20 21test('setup', function (t) { 22 mkdirp.sync(local) 23 mkdirp.sync(path.resolve(pkg, 'node_modules')) 24 fs.writeFileSync( 25 path.join(local, 'package.json'), 26 JSON.stringify(json, null, 2) 27 ) 28 t.end() 29}) 30 31test('it should install peerDependencies in same tree level as the parent package', function (t) { 32 common.npm(['install', '--loglevel=warn', './package'], EXEC_OPTS, function (err, code, stdout, stderr) { 33 t.ifError(err, 'install local package successful') 34 t.equal(code, 0, 'npm install exited with code') 35 t.match(stderr, /npm WARN @scope[/]package@0[.]0[.]0 requires a peer of underscore@[*] but none is installed[.] You must install peer dependencies yourself[.]\n/, 36 'npm install warned about unresolved peer dep') 37 38 t.end() 39 }) 40}) 41