Skip to content

Commit 4cd52ec

Browse files
committed
fix: fail-on with severity-threshold
1 parent 6e168de commit 4cd52ec

File tree

4 files changed

+364
-0
lines changed

4 files changed

+364
-0
lines changed

test/acceptance/cli-fail-on.test.ts

+25
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ const patchableResult = getWorkspaceJSON(
3939
'patchable',
4040
'vulns-result.json',
4141
);
42+
const multiSeveritiesResult = getWorkspaceJSON(
43+
'fail-on',
44+
'multiple-severities',
45+
'vulns-result.json',
46+
);
4247

4348
// @later: remove this config stuff.
4449
// Was copied straight from ../src/cli-server.js
@@ -393,6 +398,26 @@ test('test project with no vulns and --fail-on=patchable --json', async (t) => {
393398
}
394399
});
395400

401+
test('test project with multiple severities with upgrade and patch with --fail-on=patchable and --severity=high', async (t) => {
402+
try {
403+
server.setNextResponse(multiSeveritiesResult);
404+
chdirWorkspaces('fail-on');
405+
await cli.test('multiple-severities', {
406+
failOn: 'upgradable',
407+
severityThreshold: 'high',
408+
});
409+
t.fail('expected test to throw exception');
410+
} catch (err) {
411+
t.match(err, /Patchable issues/, 'should show patchable issues');
412+
t.notMatch(
413+
err,
414+
/Issues to fix by upgrading/,
415+
'should not show upgradable issues',
416+
);
417+
t.equal(err.code, 'VULNS', 'should throw exception');
418+
}
419+
});
420+
396421
// test invalid arg
397422
test('test project with --fail-on=invalid', async (t) => {
398423
try {

test/acceptance/workspaces/fail-on/multiple-severities/package-lock.json

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "upgradable-app",
3+
"version": "1.0.0",
4+
"description": "multiple severity vulns that are upgradable",
5+
"dependencies": {
6+
"yarn": "1.17.1",
7+
"ms": "^1.0.0"
8+
},
9+
"devDependencies": {}
10+
}

0 commit comments

Comments
 (0)