Skip to content

Commit 061ebb3

Browse files
author
Myles Borins
committed
test: add test-npm-install to parallel tests suite
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexis Campailla <[email protected]>
1 parent 96af474 commit 061ebb3

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/parallel/test-npm-install.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
const path = require('path');
5+
const spawn = require('child_process').spawn;
6+
const assert = require('assert');
7+
const fs = require('fs');
8+
9+
common.refreshTmpDir();
10+
11+
const npmPath = path.join(
12+
common.testDir,
13+
'..',
14+
'deps',
15+
'npm',
16+
'bin',
17+
'npm-cli.js'
18+
);
19+
20+
const args = [
21+
npmPath,
22+
'install'
23+
];
24+
25+
const pkgContent = '{}';
26+
27+
const pkgPath = path.join(common.tmpDir, 'package.json');
28+
29+
fs.writeFileSync(pkgPath, pkgContent);
30+
31+
const proc = spawn(process.execPath, args, {
32+
cwd: common.tmpDir
33+
});
34+
35+
function handleExit(code, signalCode) {
36+
assert.equal(code, 0, 'npm install should run without an error');
37+
assert.ok(signalCode === null, 'signalCode should be null');
38+
}
39+
40+
proc.on('exit', common.mustCall(handleExit));

0 commit comments

Comments
 (0)