Skip to content

Commit a060b91

Browse files
dominykasgr2m
authored andcommitted
test: write an .npmrc for package-lock related tests
Some people have `package-lock=false` disabled in their global `~/.npmrc`, so for these tests to pass reliably, an `.npmrc` needs to be present in the test folder.
1 parent 9a6176d commit a060b91

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

test/prepare.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'path';
22
import test from 'ava';
3-
import {outputJson, readJson, outputFile, readFile, pathExists} from 'fs-extra';
3+
import {outputJson, readJson, outputFile, readFile, pathExists, appendFile} from 'fs-extra';
44
import tempy from 'tempy';
55
import execa from 'execa';
66
import {stub} from 'sinon';
@@ -70,6 +70,7 @@ test('Updade package.json and package-lock.json', async t => {
7070
const packagePath = path.resolve(cwd, 'package.json');
7171
const packageLockPath = path.resolve(cwd, 'package-lock.json');
7272
await outputJson(packagePath, {version: '0.0.0-dev'});
73+
await appendFile(path.resolve(cwd, '.npmrc'), 'package-lock = true');
7374
// Create a package-lock.json file
7475
await execa('npm', ['install'], {cwd});
7576

@@ -126,6 +127,7 @@ test('Updade package.json and package-lock.json in a sub-directory', async t =>
126127
const packagePath = path.resolve(cwd, pkgRoot, 'package.json');
127128
const packageLockPath = path.resolve(cwd, pkgRoot, 'package-lock.json');
128129
await outputJson(packagePath, {version: '0.0.0-dev'});
130+
await appendFile(path.resolve(cwd, pkgRoot, '.npmrc'), 'package-lock = true');
129131
// Create a package-lock.json file
130132
await execa('npm', ['install'], {cwd: path.resolve(cwd, pkgRoot)});
131133

0 commit comments

Comments
 (0)