Skip to content

Commit 25b201c

Browse files
author
Jahed Ahmed
committedAug 12, 2021
test: use common test setup
createCLITestHarness has some regressions like using the current working directory (via path.resolve with a relative path) which we know changes due to misuse for process.chdir in other tests.
1 parent fa5bc2e commit 25b201c

File tree

2 files changed

+10
-27
lines changed

2 files changed

+10
-27
lines changed
 

‎test/jest/acceptance/snyk-test-all-projects-exit-codes.spec.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
import { createCLITestHarness } from '../util/snyk-cli-test-harness';
1+
import { createProject } from '../util/createProject';
2+
import { runSnykCLI } from '../util/runSnykCLI';
23

34
jest.setTimeout(1000 * 60 * 5);
45

56
describe('snyk test -all-projects with one project that has errors', () => {
67
describe('and another that has issues (vulnerabilities)', () => {
78
it('should exit with exit code 1', async () => {
8-
const test = createCLITestHarness(
9+
const project = await createProject(
910
'snyk-test-all-projects-exit-codes/project-with-issues-and-project-with-error',
1011
);
11-
const { code, stderr } = await test.test();
12+
const { code, stderr } = await runSnykCLI(`test --all-projects`, {
13+
cwd: project.path(),
14+
});
1215
expect(code).toEqual(1);
1316
expect(stderr).toContain(
1417
'1/2 potential projects failed to get dependencies. Run with `-d` for debug output.',
@@ -19,10 +22,12 @@ describe('snyk test -all-projects with one project that has errors', () => {
1922
describe('and another has no issues (vulnerabilities)', () => {
2023
// note: actually, this is a bug. It should really have exit code 2, but that is a big change that we need to do
2124
it('should exit with exit code 0', async () => {
22-
const test = createCLITestHarness(
25+
const project = await createProject(
2326
'snyk-test-all-projects-exit-codes/project-with-no-issues-and-project-with-error',
2427
);
25-
const { code, stderr } = await test.test();
28+
const { code, stderr } = await runSnykCLI(`test --all-projects`, {
29+
cwd: project.path(),
30+
});
2631
expect(code).toEqual(0);
2732
expect(stderr).toContain(
2833
'1/2 potential projects failed to get dependencies. Run with `-d` for debug output.',

‎test/jest/util/snyk-cli-test-harness.ts

-22
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.