Skip to content

Commit

Permalink
Merge pull request #3442 from snyk/chore/fix-windows-tests
Browse files Browse the repository at this point in the history
chore: fix windows tests
  • Loading branch information
ipapast authored Jul 7, 2022
2 parents 8fe078c + bbe1e6a commit 0c93faa
Showing 1 changed file with 34 additions and 48 deletions.
82 changes: 34 additions & 48 deletions test/jest/acceptance/iac/test-directory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,61 +236,47 @@ describe('Directory scan', () => {
expect(exitCode).toBe(1);
});
});
});

describe('directory with files that can not be parsed', () => {
beforeEach(() => {
server.setFeatureFlag(IAC_CLI_OUTPUT_FF, true);
});
afterEach(() => {
server.restore();
});
it('prints all invalid paths', async () => {
const { stdout, exitCode } = await run(
`snyk iac test ./iac/only-invalid`,
);
expect(stdout).toContain(
' Failed to parse YAML file' +
EOL +
` Path: ${pathLib.join(
'iac',
'only-invalid',
'invalid-file1.yml',
)}` +
EOL +
` ${pathLib.join(
'iac',
'only-invalid',
'invalid-file2.yaml',
)}`,
);
expect(exitCode).toBe(2);
});
it('prints all errors and paths in --json', async () => {
const { stdout, exitCode } = await run(
`snyk iac test ./iac/only-invalid --json`,
);

expect(isValidJSONString(stdout)).toBe(true);
expect(JSON.parse(stdout).length).toBe(2);

expect(stdout).toContain('"ok": false');
expect(stdout).toContain('"error": "Failed to parse YAML file"');
expect(stdout).toContain(
`"path": "${pathLib.join(
describe('directory with files that can not be parsed', () => {
beforeEach(() => {
server.setFeatureFlag(IAC_CLI_OUTPUT_FF, true);
});
afterEach(() => {
server.restore();
});
it('prints all invalid paths', async () => {
const { stdout, exitCode } = await run(
`snyk iac test ./iac/only-invalid`,
);
expect(stdout).toContain(
' Failed to parse YAML file' +
EOL +
` Path: ${pathLib.join(
'iac',
'only-invalid',
'invalid-file1.yml',
)}"`,
);
expect(stdout).toContain(
`"path": "${pathLib.join(
)}` +
EOL +
` ${pathLib.join(
'iac',
'only-invalid',
'invalid-file2.yaml',
)}"`,
);
expect(exitCode).toBe(2);
});
)}`,
);
expect(exitCode).toBe(2);
});
it('prints all errors and paths in --json', async () => {
const { stdout, exitCode } = await run(
`snyk iac test ./iac/only-invalid --json`,
);

expect(isValidJSONString(stdout)).toBe(true);

expect(JSON.parse(stdout).length).toBe(2);
expect(stdout).toContain('"ok": false');
expect(stdout).toContain('"error": "Failed to parse YAML file"');
expect(exitCode).toBe(2);
});
});

Expand Down

0 comments on commit 0c93faa

Please sign in to comment.