Skip to content

Commit 7dfd3ea

Browse files
authored
Merge pull request #1661 from snyk/test/fix-flake-with-dev-count-analysis
Cleanup tests
2 parents 8cd9fbf + 02c99b8 commit 7dfd3ea

File tree

3 files changed

+2
-228
lines changed

3 files changed

+2
-228
lines changed

test/acceptance/cli-args.test.ts

-112
Original file line numberDiff line numberDiff line change
@@ -346,118 +346,6 @@ test('`test --json-file-output no value produces error message`', (t) => {
346346
optionsToTest.forEach(validate);
347347
});
348348

349-
test('`test --json-file-output can save JSON output to file while sending human readable output to stdout`', (t) => {
350-
t.plan(2);
351-
const tmpFolder = randomTmpFolderPath();
352-
const jsonPath = path.normalize(
353-
`${tmpFolder}/snyk-direct-json-test-output.json`,
354-
);
355-
356-
const testFixture =
357-
'test/acceptance/workspaces/npm-package-no-vulns/package.json';
358-
359-
exec(
360-
`node ${main} test --file=${testFixture} --json-file-output=${jsonPath}`,
361-
(err, stdout) => {
362-
if (err) {
363-
console.log('CLI stdout: ', stdout);
364-
throw err;
365-
}
366-
if (!existsSync(jsonPath)) {
367-
console.log('CLI stdout: ', stdout);
368-
}
369-
const outputFileContents = readFileSync(jsonPath, 'utf-8');
370-
const jsonObj = JSON.parse(outputFileContents);
371-
const okValue = jsonObj.ok as boolean;
372-
373-
t.match(stdout, 'Organization:', 'contains human readable output');
374-
t.ok(okValue, 'JSON output ok');
375-
},
376-
);
377-
});
378-
379-
test('`test --json-file-output produces same JSON output as normal JSON output to stdout`', (t) => {
380-
t.plan(1);
381-
const tmpFolder = randomTmpFolderPath();
382-
const jsonPath = path.normalize(
383-
`${tmpFolder}/snyk-direct-json-test-output.json`,
384-
);
385-
const testFixture =
386-
'test/acceptance/workspaces/npm-package-no-vulns/package.json';
387-
exec(
388-
`node ${main} test --file=${testFixture} --json --json-file-output=${jsonPath}`,
389-
(err, stdout) => {
390-
if (err) {
391-
console.log('CLI stdout: ', stdout);
392-
throw err;
393-
}
394-
const stdoutJson = stdout;
395-
if (!existsSync(jsonPath)) {
396-
console.log('CLI stdout: ', stdout);
397-
}
398-
const outputFileContents = readFileSync(jsonPath, 'utf-8');
399-
400-
t.equals(stdoutJson, outputFileContents);
401-
},
402-
);
403-
});
404-
405-
test('`test --json-file-output can handle a relative path`', (t) => {
406-
t.plan(1);
407-
const tmpFolder = randomTmpFolderPath();
408-
const outputPath = path.normalize(
409-
`${tmpFolder}/snyk-direct-json-test-output.json`,
410-
);
411-
const testFixture =
412-
'test/acceptance/workspaces/npm-package-no-vulns/package.json';
413-
exec(
414-
`node ${main} test --file=${testFixture} --json --json-file-output=${outputPath}`,
415-
(err, stdout) => {
416-
if (err) {
417-
console.log('CLI stdout: ', stdout);
418-
throw err;
419-
}
420-
const stdoutJson = stdout;
421-
if (!existsSync(outputPath)) {
422-
console.log('CLI stdout: ', stdout);
423-
}
424-
const outputFileContents = readFileSync(outputPath, 'utf-8');
425-
426-
t.equals(stdoutJson, outputFileContents);
427-
},
428-
);
429-
});
430-
431-
test(
432-
'`test --json-file-output can handle an absolute path`',
433-
{ skip: isWindows },
434-
(t) => {
435-
t.plan(1);
436-
const tmpFolder = randomTmpFolderPath();
437-
const outputPath = path.normalize(
438-
`${tmpFolder}/snyk-direct-json-test-output.json`,
439-
);
440-
const testFixture =
441-
'test/acceptance/workspaces/npm-package-no-vulns/package.json';
442-
exec(
443-
`node ${main} test --file=${testFixture} --json --json-file-output=${outputPath}`,
444-
(err, stdout) => {
445-
if (err) {
446-
console.log('CLI stdout: ', stdout);
447-
throw err;
448-
}
449-
const stdoutJson = stdout;
450-
if (!existsSync(outputPath)) {
451-
console.log('CLI stdout: ', stdout);
452-
}
453-
const outputFileContents = readFileSync(outputPath, 'utf-8');
454-
455-
t.equals(stdoutJson, outputFileContents);
456-
},
457-
);
458-
},
459-
);
460-
461349
test('flags not allowed with --sarif', (t) => {
462350
t.plan(4);
463351
exec(`node ${main} test iac --sarif --json`, (err, stdout) => {

test/dev-count-analysis.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
hashData,
88
} from '../src/lib/monitor/dev-count-analysis';
99

10-
const testTimeout = 30000;
10+
const testTimeout = 60000;
1111
describe('cli dev count via git log analysis', () => {
1212
let expectedContributorUserIds: string[] = [];
1313
let expectedMergeOnlyUserIds: string[] = [];
@@ -52,7 +52,7 @@ describe('cli dev count via git log analysis', () => {
5252
expectedMergeOnlyUserIds = uniqueEmailsContainingOnlyMergeCommits.map(
5353
hashData,
5454
);
55-
});
55+
}, testTimeout);
5656

5757
it(
5858
'returns contributors',

test/system/cli-json-file-output.test.ts

-114
This file was deleted.

0 commit comments

Comments
 (0)