Skip to content

Commit 71d46aa

Browse files
authoredJan 11, 2021
test: remove usage of npx in tests (#241)
1 parent 4f12838 commit 71d46aa

File tree

1 file changed

+24
-41
lines changed

1 file changed

+24
-41
lines changed
 

‎test/test.cli.ts

+24-41
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,34 @@ describe('cli', function () {
2626
});
2727

2828
it('should show output for failures', async () => {
29-
const res = await execa('npx', ['linkinator', 'test/fixtures/basic'], {
29+
const res = await execa('linkinator', ['test/fixtures/basic'], {
3030
reject: false,
3131
});
3232
assert.match(res.stderr, /ERROR: Detected 1 broken links/);
3333
});
3434

3535
it('should pass successful markdown scan', async () => {
36-
const res = await execa('npx', [
37-
'linkinator',
38-
'test/fixtures/markdown/README.md',
39-
]);
36+
const res = await execa('linkinator', ['test/fixtures/markdown/README.md']);
4037
assert.match(res.stderr, /Successfully scanned/);
4138
});
4239

4340
it('should allow multiple paths', async () => {
44-
const res = await execa('npx', [
45-
'linkinator',
41+
const res = await execa('linkinator', [
4642
'test/fixtures/markdown/unlinked.md',
4743
'test/fixtures/markdown/README.md',
4844
]);
4945
assert.match(res.stderr, /Successfully scanned/);
5046
});
5147

5248
it('should show help if no params are provided', async () => {
53-
const res = await execa('npx', ['linkinator'], {
49+
const res = await execa('linkinator', {
5450
reject: false,
5551
});
5652
assert.match(res.stdout, /\$ linkinator LOCATION \[ --arguments \]/);
5753
});
5854

5955
it('should flag skipped links', async () => {
60-
const res = await execa('npx', [
61-
'linkinator',
56+
const res = await execa('linkinator', [
6257
'--verbosity',
6358
'INFO',
6459
'--skip',
@@ -69,8 +64,7 @@ describe('cli', function () {
6964
});
7065

7166
it('should provide CSV if asked nicely', async () => {
72-
const res = await execa('npx', [
73-
'linkinator',
67+
const res = await execa('linkinator', [
7468
'--format',
7569
'csv',
7670
'test/fixtures/markdown/README.md',
@@ -79,8 +73,7 @@ describe('cli', function () {
7973
});
8074

8175
it('should provide JSON if asked nicely', async () => {
82-
const res = await execa('npx', [
83-
'linkinator',
76+
const res = await execa('linkinator', [
8477
'--format',
8578
'json',
8679
'test/fixtures/markdown/README.md',
@@ -90,17 +83,15 @@ describe('cli', function () {
9083
});
9184

9285
it('should not show links if --silent', async () => {
93-
const res = await execa('npx', [
94-
'linkinator',
86+
const res = await execa('linkinator', [
9587
'--silent',
9688
'test/fixtures/markdown/README.md',
9789
]);
9890
assert.notMatch(res.stdout, /\[/);
9991
});
10092

10193
it('should not show 200 links if verbosity is ERROR with JSON', async () => {
102-
const res = await execa('npx', [
103-
'linkinator',
94+
const res = await execa('linkinator', [
10495
'--verbosity',
10596
'ERROR',
10697
'--format',
@@ -114,8 +105,7 @@ describe('cli', function () {
114105
});
115106

116107
it('should accept a server-root', async () => {
117-
const res = await execa('npx', [
118-
'linkinator',
108+
const res = await execa('linkinator', [
119109
'--markdown',
120110
'--server-root',
121111
'test/fixtures/markdown',
@@ -125,29 +115,24 @@ describe('cli', function () {
125115
});
126116

127117
it('should accept globs', async () => {
128-
const res = await execa('npx', [
129-
'linkinator',
118+
const res = await execa('linkinator', [
130119
'test/fixtures/markdown/*.md',
131120
'test/fixtures/markdown/**/*.md',
132121
]);
133122
assert.match(res.stderr, /Successfully scanned/);
134123
});
135124

136125
it('should throw on invalid format', async () => {
137-
const res = await execa(
138-
'npx',
139-
['linkinator', './README.md', '--format', 'LOL'],
140-
{
141-
reject: false,
142-
}
143-
);
126+
const res = await execa('linkinator', ['./README.md', '--format', 'LOL'], {
127+
reject: false,
128+
});
144129
assert.match(res.stderr, /FORMAT must be/);
145130
});
146131

147132
it('should throw on invalid verbosity', async () => {
148133
const res = await execa(
149-
'npx',
150-
['linkinator', './README.md', '--VERBOSITY', 'LOL'],
134+
'linkinator',
135+
['./README.md', '--VERBOSITY', 'LOL'],
151136
{
152137
reject: false,
153138
}
@@ -157,8 +142,8 @@ describe('cli', function () {
157142

158143
it('should throw when verbosity and silent are flagged', async () => {
159144
const res = await execa(
160-
'npx',
161-
['linkinator', './README.md', '--verbosity', 'DEBUG', '--silent'],
145+
'linkinator',
146+
['./README.md', '--verbosity', 'DEBUG', '--silent'],
162147
{
163148
reject: false,
164149
}
@@ -168,8 +153,8 @@ describe('cli', function () {
168153

169154
it('should show no output for verbosity=NONE', async () => {
170155
const res = await execa(
171-
'npx',
172-
['linkinator', 'test/fixtures/basic', '--verbosity', 'NONE'],
156+
'linkinator',
157+
['test/fixtures/basic', '--verbosity', 'NONE'],
173158
{
174159
reject: false,
175160
}
@@ -181,8 +166,8 @@ describe('cli', function () {
181166

182167
it('should show callstacks for verbosity=DEBUG', async () => {
183168
const res = await execa(
184-
'npx',
185-
['linkinator', 'test/fixtures/basic', '--verbosity', 'DEBUG'],
169+
'linkinator',
170+
['test/fixtures/basic', '--verbosity', 'DEBUG'],
186171
{
187172
reject: false,
188173
}
@@ -192,8 +177,7 @@ describe('cli', function () {
192177
});
193178

194179
it('should allow passing a config', async () => {
195-
const res = await execa('npx', [
196-
'linkinator',
180+
const res = await execa('linkinator', [
197181
'test/fixtures/basic',
198182
'--config',
199183
'test/fixtures/config/skip-array-config.json',
@@ -223,8 +207,7 @@ describe('cli', function () {
223207
enableDestroy(server);
224208
await new Promise<void>(r => server.listen(port, r));
225209

226-
const res = await execa('npx', [
227-
'linkinator',
210+
const res = await execa('linkinator', [
228211
'--retry',
229212
'test/fixtures/retryCLI',
230213
]);

0 commit comments

Comments
 (0)
Please sign in to comment.