diff --git a/.circleci/config.yml b/.circleci/config.yml index a13ce5f82d..300ddc6518 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -500,7 +500,7 @@ workflows: - test-windows: name: Windows, Node 12 - Packages, Jest, Acceptance, System tests context: nodejs-install - node_version: '12.16.2' + node_version: '12.21.0' jest_tests: true acceptance_tests: true system_tests: true @@ -510,7 +510,7 @@ workflows: - test-windows: name: Windows, Node 12 - "Root" tap tests context: nodejs-install - node_version: '12.16.2' + node_version: '12.21.0' root_tap_tests: true requires: - Regression Test @@ -552,7 +552,7 @@ workflows: - test-linux: name: Linux, Node 12 - Packages, Jest, Acceptance, System tests context: nodejs-install - node_version: '12.16.2' + node_version: '12.21.0' jest_tests: true acceptance_tests: true system_tests: true @@ -562,7 +562,7 @@ workflows: - test-linux: name: Linux, Node 12 - "Root" tap tests context: nodejs-install - node_version: '12.16.2' + node_version: '12.21.0' root_tap_tests: true requires: - Regression Test diff --git a/package.json b/package.json index f11969f5b1..8149de9fde 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "test:acceptance": "tap test/acceptance/**/*.test.* test/acceptance/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register", "test:acceptance-windows": "tap test/acceptance/**/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register", "test:system": "tap test/system/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register", - "test:jest": "jest test/*", + "test:jest": "jest --runInBand test/*", "test:packages-unit": "jest packages/**/test/unit/*.spec.ts", "test:packages-acceptance": "jest packages/**/test/acceptance/*.spec.ts", "test:test": "tap test/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register", @@ -131,7 +131,7 @@ "devDependencies": { "@types/agent-base": "^4.2.1", "@types/diff": "^3.5.2", - "@types/jest": "^25.2.3", + "@types/jest": "^26.0.20", "@types/lodash": "^4.14.161", "@types/needle": "^2.0.4", "@types/node": "^10.0.0", @@ -143,7 +143,7 @@ "@typescript-eslint/parser": "^2.0.0", "eslint": "6.8.0", "eslint-config-prettier": "^6.1.0", - "jest": "^25.5.4", + "jest": "^26.6.3", "lodash": "^4.17.20", "lodash.countby": "^4.6.0", "lodash.every": "^4.6.0", @@ -157,7 +157,7 @@ "sinon": "^4.0.0", "tap": "^12.6.1", "tape": "^4.0.0", - "ts-jest": "^25.5.1", + "ts-jest": "^26.5.2", "ts-node": "^8.0.0", "tslint": "^5.14.0", "typescript": "^3.4.1" diff --git a/test/cli-json-file-output.spec.ts b/test/cli-json-file-output.spec.ts index 28e93b4d1b..25714efe23 100644 --- a/test/cli-json-file-output.spec.ts +++ b/test/cli-json-file-output.spec.ts @@ -20,21 +20,18 @@ describe('test --json-file-output ', () => { ); it( '`can save JSON output to file while sending human readable output to stdout`', - async (done) => { - return exec( - `node ${main} test ${noVulnsProjectPath} --json-file-output=snyk-direct-json-test-output.json`, - async (err, stdout) => { + (done) => { + const jsonOutputFilename = `${uuidv4()}.json`; + exec( + `node ${main} test ${noVulnsProjectPath} --json-file-output=${jsonOutputFilename}`, + (err, stdout) => { if (err) { throw err; } - // give file a little time to be finished to be written - await new Promise((r) => setTimeout(r, 5000)); + expect(stdout).toMatch('Organization:'); - const outputFileContents = readFileSync( - 'snyk-direct-json-test-output.json', - 'utf-8', - ); - unlinkSync('./snyk-direct-json-test-output.json'); + const outputFileContents = readFileSync(jsonOutputFilename, 'utf-8'); + unlinkSync(`./${jsonOutputFilename}`); const jsonObj = JSON.parse(outputFileContents); const okValue = jsonObj.ok as boolean; expect(okValue).toBeTruthy(); @@ -48,8 +45,9 @@ describe('test --json-file-output ', () => { it( '`test --json-file-output produces same JSON output as normal JSON output to stdout`', (done) => { + const jsonOutputFilename = `${uuidv4()}.json`; return exec( - `node ${main} test ${noVulnsProjectPath} --json --json-file-output=snyk-direct-json-test-output.json`, + `node ${main} test ${noVulnsProjectPath} --json --json-file-output=${jsonOutputFilename}`, async (err, stdout) => { if (err) { throw err; @@ -57,11 +55,8 @@ describe('test --json-file-output ', () => { // give file a little time to be finished to be written await new Promise((r) => setTimeout(r, 3000)); const stdoutJson = stdout; - const outputFileContents = readFileSync( - 'snyk-direct-json-test-output.json', - 'utf-8', - ); - unlinkSync('./snyk-direct-json-test-output.json'); + const outputFileContents = readFileSync(jsonOutputFilename, 'utf-8'); + unlinkSync(`./${jsonOutputFilename}`); expect(stdoutJson).toEqual(outputFileContents); done(); },