Skip to content

Commit

Permalink
Merge pull request #1661 from snyk/test/fix-flake-with-dev-count-anal…
Browse files Browse the repository at this point in the history
…ysis

Cleanup tests
  • Loading branch information
maxjeffos committed Feb 26, 2021
2 parents 8cd9fbf + 02c99b8 commit 7dfd3ea
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 228 deletions.
112 changes: 0 additions & 112 deletions test/acceptance/cli-args.test.ts
Expand Up @@ -346,118 +346,6 @@ test('`test --json-file-output no value produces error message`', (t) => {
optionsToTest.forEach(validate);
});

test('`test --json-file-output can save JSON output to file while sending human readable output to stdout`', (t) => {
t.plan(2);
const tmpFolder = randomTmpFolderPath();
const jsonPath = path.normalize(
`${tmpFolder}/snyk-direct-json-test-output.json`,
);

const testFixture =
'test/acceptance/workspaces/npm-package-no-vulns/package.json';

exec(
`node ${main} test --file=${testFixture} --json-file-output=${jsonPath}`,
(err, stdout) => {
if (err) {
console.log('CLI stdout: ', stdout);
throw err;
}
if (!existsSync(jsonPath)) {
console.log('CLI stdout: ', stdout);
}
const outputFileContents = readFileSync(jsonPath, 'utf-8');
const jsonObj = JSON.parse(outputFileContents);
const okValue = jsonObj.ok as boolean;

t.match(stdout, 'Organization:', 'contains human readable output');
t.ok(okValue, 'JSON output ok');
},
);
});

test('`test --json-file-output produces same JSON output as normal JSON output to stdout`', (t) => {
t.plan(1);
const tmpFolder = randomTmpFolderPath();
const jsonPath = path.normalize(
`${tmpFolder}/snyk-direct-json-test-output.json`,
);
const testFixture =
'test/acceptance/workspaces/npm-package-no-vulns/package.json';
exec(
`node ${main} test --file=${testFixture} --json --json-file-output=${jsonPath}`,
(err, stdout) => {
if (err) {
console.log('CLI stdout: ', stdout);
throw err;
}
const stdoutJson = stdout;
if (!existsSync(jsonPath)) {
console.log('CLI stdout: ', stdout);
}
const outputFileContents = readFileSync(jsonPath, 'utf-8');

t.equals(stdoutJson, outputFileContents);
},
);
});

test('`test --json-file-output can handle a relative path`', (t) => {
t.plan(1);
const tmpFolder = randomTmpFolderPath();
const outputPath = path.normalize(
`${tmpFolder}/snyk-direct-json-test-output.json`,
);
const testFixture =
'test/acceptance/workspaces/npm-package-no-vulns/package.json';
exec(
`node ${main} test --file=${testFixture} --json --json-file-output=${outputPath}`,
(err, stdout) => {
if (err) {
console.log('CLI stdout: ', stdout);
throw err;
}
const stdoutJson = stdout;
if (!existsSync(outputPath)) {
console.log('CLI stdout: ', stdout);
}
const outputFileContents = readFileSync(outputPath, 'utf-8');

t.equals(stdoutJson, outputFileContents);
},
);
});

test(
'`test --json-file-output can handle an absolute path`',
{ skip: isWindows },
(t) => {
t.plan(1);
const tmpFolder = randomTmpFolderPath();
const outputPath = path.normalize(
`${tmpFolder}/snyk-direct-json-test-output.json`,
);
const testFixture =
'test/acceptance/workspaces/npm-package-no-vulns/package.json';
exec(
`node ${main} test --file=${testFixture} --json --json-file-output=${outputPath}`,
(err, stdout) => {
if (err) {
console.log('CLI stdout: ', stdout);
throw err;
}
const stdoutJson = stdout;
if (!existsSync(outputPath)) {
console.log('CLI stdout: ', stdout);
}
const outputFileContents = readFileSync(outputPath, 'utf-8');

t.equals(stdoutJson, outputFileContents);
},
);
},
);

test('flags not allowed with --sarif', (t) => {
t.plan(4);
exec(`node ${main} test iac --sarif --json`, (err, stdout) => {
Expand Down
4 changes: 2 additions & 2 deletions test/dev-count-analysis.spec.ts
Expand Up @@ -7,7 +7,7 @@ import {
hashData,
} from '../src/lib/monitor/dev-count-analysis';

const testTimeout = 30000;
const testTimeout = 60000;
describe('cli dev count via git log analysis', () => {
let expectedContributorUserIds: string[] = [];
let expectedMergeOnlyUserIds: string[] = [];
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('cli dev count via git log analysis', () => {
expectedMergeOnlyUserIds = uniqueEmailsContainingOnlyMergeCommits.map(
hashData,
);
});
}, testTimeout);

it(
'returns contributors',
Expand Down
114 changes: 0 additions & 114 deletions test/system/cli-json-file-output.test.ts

This file was deleted.

0 comments on commit 7dfd3ea

Please sign in to comment.