-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
591cc71
commit 5a74669
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { runSnykCLI } from '../util/runSnykCLI'; | ||
|
||
describe('the IPC', () => { | ||
const env = { | ||
...process.env, | ||
}; | ||
|
||
describe('does not sends errors', () => { | ||
it('for successful runs', async () => { | ||
const { code, stderr } = await runSnykCLI( | ||
`test --print-graph ./test/fixtures/npm/with-vulnerable-lodash-dep -d`, | ||
{ | ||
env, | ||
}, | ||
); | ||
|
||
expect(code).toEqual(0); | ||
expect(stderr).not.toContain('Error file contained '); | ||
}); | ||
|
||
it('when vulnerabilities are found', async () => { | ||
const { code, stderr } = await runSnykCLI(`test semver@2 -d`, { | ||
env, | ||
}); | ||
|
||
expect(code).toEqual(1); | ||
expect(stderr).not.toContain('No data was sent through the IPC file.'); | ||
expect(stderr).not.toContain('Error file contained '); | ||
}); | ||
|
||
it('for sarif output', async () => { | ||
const { code, stderr } = await runSnykCLI( | ||
`test ./test/fixtures/empty --sarif -d`, | ||
{ | ||
env, | ||
}, | ||
); | ||
|
||
// For exit code 2 we will check the IPC file | ||
expect(code).toEqual(2); | ||
expect(stderr).toContain('No data was sent through the IPC file.'); | ||
expect(stderr).not.toContain('Error file contained '); | ||
}); | ||
}); | ||
|
||
describe('sends and receives errors', () => { | ||
it('for no supported files found', async () => { | ||
const { code, stdout, stderr } = await runSnykCLI( | ||
`test ./test/fixtures/empty -d`, | ||
{ | ||
env, | ||
}, | ||
); | ||
|
||
expect(code).toEqual(3); | ||
expect(stdout).toContain('SNYK-CLI-0000'); | ||
expect(stderr).toContain('SNYK-CLI-0000'); | ||
expect(stderr).toContain('Error file contained '); | ||
}); | ||
|
||
it('for errors thrown', async () => { | ||
const { code, stdout, stderr } = await runSnykCLI(`test ./not_here -d`, { | ||
env, | ||
}); | ||
|
||
expect(code).toEqual(2); | ||
expect(stdout).toContain('SNYK-CLI-0000'); | ||
expect(stderr).toContain('SNYK-CLI-0000'); | ||
expect(stderr).toContain('Error file contained '); | ||
}); | ||
}); | ||
}); |