/
test.js
35 lines (27 loc) · 1006 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import process from 'node:process';
import test from 'ava';
import {execa} from 'execa';
import {resolveGlobal, resolveGlobalSilent} from './index.js';
test('resolveGlobal - npm', async t => {
await execa('npm', ['uninstall', '--global', 'cat-names']);
t.throws(() => {
resolveGlobal('./index.js');
});
t.throws(() => {
resolveGlobal('cat-names');
});
t.regex(resolveGlobal('npm'), /npm/);
await execa('npm', ['install', '--global', 'cat-names']);
t.regex(resolveGlobal('cat-names'), /cat-names/);
await execa('npm', ['uninstall', '--global', 'cat-names']);
});
const testFailingCi = process.env.CI ? test.failing : test;
testFailingCi('resolveGlobal - yarn', async t => {
await execa('npm', ['install', '--global', 'yarn']);
await execa('yarn', ['global', 'add', 'dog-names']);
t.regex(resolveGlobal('dog-names'), /dog-names/);
await execa('yarn', ['global', 'remove', 'dog-names']);
});
test('resolveGlobalSilent', t => {
t.is(resolveGlobalSilent('./index.js'), undefined);
});