Skip to content

Commit

Permalink
Try fixing tests on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Aug 9, 2019
1 parent cc7b829 commit 845e75f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/test.js
Expand Up @@ -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(/^[^/]+/, '')
Expand Down

0 comments on commit 845e75f

Please sign in to comment.