Skip to content

Commit

Permalink
test: add test-npm-install to parallel tests suite
Browse files Browse the repository at this point in the history
Currently we are not testing that `npm install` works.

This is a very naive / basic test that shells out to `npm install`
in an empty `tempDir`. While this test will not be able to check
that `npm install` is 100% working, it should catch certain edge
cases that break it.

PR-URL: #5166
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Alexis Campailla <orangemocha@nodejs.org>
  • Loading branch information
Myles Borins committed Mar 30, 2016
1 parent b258ddd commit 7520100
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/parallel/test-npm-install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use strict';
const common = require('../common');

const path = require('path');
const spawn = require('child_process').spawn;
const assert = require('assert');
const fs = require('fs');

common.refreshTmpDir();

const npmPath = path.join(
common.testDir,
'..',
'deps',
'npm',
'bin',
'npm-cli.js'
);

const args = [
npmPath,
'install'
];

const pkgContent = '{}';

const pkgPath = path.join(common.tmpDir, 'package.json');

fs.writeFileSync(pkgPath, pkgContent);

const proc = spawn(process.execPath, args, {
cwd: common.tmpDir
});

function handleExit(code, signalCode) {
assert.equal(code, 0, 'npm install should run without an error');
assert.ok(signalCode === null, 'signalCode should be null');
}

proc.on('exit', common.mustCall(handleExit));

0 comments on commit 7520100

Please sign in to comment.