From 3c044983eacb65e9f7cd55f96a0b35c6aec65523 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Tue, 7 May 2019 11:56:04 +0200 Subject: [PATCH 1/2] Improve test for options.preferLocal --- package.json | 1 - test.js | 16 +++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index fed7dec3f4..e4ee3f031e 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test.js b/test.js index 2cb3095348..0ede572ef1 100644 --- a/test.js +++ b/test.js @@ -184,19 +184,9 @@ 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: ''}}); + await t.throwsAsync(execa('ava', ['--version'], {preferLocal: false, env: {PATH: ''}}), /spawn .* ENOENT/); }); test.serial('localDir option', async t => { From d8b8faf32c8aa6b1f284c2ca8dedd99e92e1d5bc Mon Sep 17 00:00:00 2001 From: ehmicky Date: Tue, 7 May 2019 12:25:07 +0200 Subject: [PATCH 2/2] Fix test on Windows --- test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test.js b/test.js index 0ede572ef1..3f0f21f12b 100644 --- a/test.js +++ b/test.js @@ -186,7 +186,8 @@ test('stripFinalNewline option', async t => { test('preferLocal option', async t => { await execa('ava', ['--version'], {env: {PATH: ''}}); - await t.throwsAsync(execa('ava', ['--version'], {preferLocal: false, env: {PATH: ''}}), /spawn .* ENOENT/); + 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 => {