Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 061ebb3

Browse filesBrowse 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 <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Alexis Campailla <orangemocha@nodejs.org>
1 parent 96af474 commit 061ebb3
Copy full SHA for 061ebb3

File tree

Expand file treeCollapse file tree

1 file changed

+40
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+40
-0
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-npm-install.js‎

Copy file name to clipboard
+40Lines changed: 40 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.