Skip to content

Commit 77336a0

Browse files
author
Jahed Ahmed
authoredJul 19, 2021
Merge pull request #2099 from snyk/test/migrate-trust-policies-jest
test: migrate trust-policies to jest
2 parents b227f78 + e2106f1 commit 77336a0

File tree

2 files changed

+41
-38
lines changed

2 files changed

+41
-38
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { createProject } from '../../util/createProject';
2+
import { requireSnykToken } from '../../util/requireSnykToken';
3+
import { runSnykCLI } from '../../util/runSnykCLI';
4+
5+
jest.setTimeout(1000 * 60);
6+
7+
test('`snyk test` detects suggested ignore policies', async () => {
8+
const project = await createProject('qs-package');
9+
const { code, stdout } = await runSnykCLI('test', {
10+
cwd: project.path(),
11+
env: {
12+
...process.env,
13+
SNYK_TOKEN: requireSnykToken(),
14+
},
15+
});
16+
17+
expect(code).toEqual(1);
18+
expect(stdout).toMatch(
19+
'suggests ignoring this issue, with reason: test trust policies',
20+
);
21+
expect(stdout).toMatch('npm:hawk:20160119');
22+
expect(stdout).toMatch('npm:request:20160119');
23+
});
24+
25+
test('`snyk test --trust-policies` applies suggested ignore policies', async () => {
26+
const project = await createProject('qs-package');
27+
const { code, stdout } = await runSnykCLI('test --trust-policies', {
28+
cwd: project.path(),
29+
env: {
30+
...process.env,
31+
SNYK_TOKEN: requireSnykToken(),
32+
},
33+
});
34+
35+
expect(code).toEqual(1);
36+
expect(stdout).not.toMatch(
37+
'suggests ignoring this issue, with reason: test trust policies',
38+
);
39+
expect(stdout).not.toMatch('npm:hawk:20160119');
40+
expect(stdout).not.toMatch('npm:request:20160119');
41+
});

‎test/policy-trust-deep.test.ts

-38
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.