Skip to content

Commit

Permalink
Improve test for options.preferLocal (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored and sindresorhus committed May 7, 2019
1 parent 51b1cef commit 575d464
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -50,7 +50,6 @@
"devDependencies": {
"@types/node": "^11.12.2",
"ava": "^1.4.1",
"cat-names": "^2.0.0",
"coveralls": "^3.0.3",
"delay": "^4.1.0",
"is-running": "^2.1.0",
Expand Down
17 changes: 4 additions & 13 deletions test.js
Expand Up @@ -184,19 +184,10 @@ test('stripFinalNewline option', async t => {
t.is(stdout, 'foo\n');
});

test.serial('preferLocal option', async t => {
t.true((await execa('cat-names')).stdout.length > 2);

if (process.platform === 'win32') {
// TODO: figure out how to make the below not hang on Windows
return;
}

// Account for npm adding local binaries to the PATH
const _path = process.env.PATH;
process.env.PATH = '';
await t.throwsAsync(execa('cat-names', {preferLocal: false}), /spawn .* ENOENT/);
process.env.PATH = _path;
test('preferLocal option', async t => {
await execa('ava', ['--version'], {env: {PATH: ''}});
const errorRegExp = process.platform === 'win32' ? /not recognized/ : /spawn ava ENOENT/;
await t.throwsAsync(execa('ava', ['--version'], {preferLocal: false, env: {PATH: ''}}), errorRegExp);
});

test.serial('localDir option', async t => {
Expand Down

0 comments on commit 575d464

Please sign in to comment.