diff --git a/test/test.js b/test/test.js index 90089cffe1..891f8d0516 100644 --- a/test/test.js +++ b/test/test.js @@ -73,20 +73,22 @@ test('stripFinalNewline in sync mode on failure', t => { t.is(stderr, 'foo'); }); +const pathKey = process.platform === 'win32' ? 'Path' : 'PATH'; + test('preferLocal: true', async t => { - await t.notThrowsAsync(execa('ava', ['--version'], {preferLocal: true, env: {PATH: ''}})); + await t.notThrowsAsync(execa('ava', ['--version'], {preferLocal: true, env: {[pathKey]: ''}})); }); test('preferLocal: false', async t => { - await t.throwsAsync(execa('ava', ['--version'], {preferLocal: false, env: {PATH: ''}}), ENOENT_REGEXP); + await t.throwsAsync(execa('ava', ['--version'], {preferLocal: false, env: {[pathKey]: ''}}), ENOENT_REGEXP); }); test('preferLocal: undefined', async t => { - await t.throwsAsync(execa('ava', ['--version'], {env: {PATH: ''}}), ENOENT_REGEXP); + await t.throwsAsync(execa('ava', ['--version'], {env: {[pathKey]: ''}}), ENOENT_REGEXP); }); test('localDir option', async t => { - const command = process.platform === 'win32' ? 'echo %PATH%' : 'echo $PATH'; + const command = process.platform === 'win32' ? `echo %${pathKey}%` : `echo $${pathKey}`; const {stdout} = await execa(command, {shell: true, preferLocal: true, localDir: '/test'}); const envPaths = stdout.split(path.delimiter).map(envPath => envPath.replace(/\\/g, '/').replace(/^[^/]+/, '')