From 845e75f522ba4f8d5ebe2037e9fc3c1317568e62 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Fri, 9 Aug 2019 10:00:00 +0200 Subject: [PATCH] Try fixing tests on Windows --- test/test.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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(/^[^/]+/, '')