diff --git a/jest.config.js b/jest.config.js index 8c2b366ed0..7ba94bfecf 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,9 +1,5 @@ module.exports = { preset: 'ts-jest', - testEnvironment: 'node', - collectCoverage: false, // not collecting coverage for now - collectCoverageFrom: ['src/**/*.ts'], - coverageReporters: ['text-summary', 'html'], testMatch: [ '/test/*.spec.ts', '/test/iac-unit-tests/*.spec.ts', diff --git a/package.json b/package.json index 64740bb2ac..cab5c066aa 100644 --- a/package.json +++ b/package.json @@ -165,7 +165,7 @@ "eslint": "6.8.0", "eslint-config-prettier": "^6.1.0", "fs-extra": "^9.1.0", - "jest": "^26.6.3", + "jest": "^27.0.6", "jest-junit": "^12.0.0", "lodash": "^4.17.20", "madge": "^3.4.4", @@ -178,7 +178,7 @@ "sinon": "^4.0.0", "tap": "^12.6.1", "tap-junit": "^4.2.0", - "ts-jest": "^26.5.2", + "ts-jest": "^27.0.4", "ts-node": "^8.0.0", "typescript": "^3.4.1" }, diff --git a/packages/snyk-fix/jest.config.js b/packages/snyk-fix/jest.config.js index 65d66205d5..8824c11446 100644 --- a/packages/snyk-fix/jest.config.js +++ b/packages/snyk-fix/jest.config.js @@ -1,7 +1,3 @@ module.exports = { preset: 'ts-jest', - testEnvironment: 'node', - collectCoverage: false, // not collecting coverage for now - collectCoverageFrom: ['src/**/*.ts'], - coverageReporters: ['text-summary', 'html'], }; diff --git a/packages/snyk-fix/package.json b/packages/snyk-fix/package.json index 70237fb14b..954f935b1a 100644 --- a/packages/snyk-fix/package.json +++ b/packages/snyk-fix/package.json @@ -48,13 +48,6 @@ "strip-ansi": "6.0.0", "toml": "3.0.0" }, - "devDependencies": { - "@types/jest": "26.0.20", - "@types/node": "14.14.25", - "jest": "26.6.3", - "ts-jest": "^26.5.3", - "typescript": "4.2.4" - }, "repository": { "type": "git", "url": "https://github.com/snyk/snyk.git" diff --git a/packages/snyk-protect/jest.config.js b/packages/snyk-protect/jest.config.js index 2e02fee4e7..237777a8e9 100644 --- a/packages/snyk-protect/jest.config.js +++ b/packages/snyk-protect/jest.config.js @@ -1,9 +1,5 @@ module.exports = { preset: 'ts-jest', - testEnvironment: 'node', - collectCoverage: false, // not collecting coverage for now - collectCoverageFrom: ['src/**/*.ts'], - coverageReporters: ['text-summary', 'html'], testMatch: [ '/test/**/*.spec.ts', '\\test\\**\\*.spec.ts', // for Windows diff --git a/packages/snyk-protect/test/unit/explore-node-modules.spec.ts b/packages/snyk-protect/test/unit/explore-node-modules.spec.ts index 0d89595f13..593e67a52e 100644 --- a/packages/snyk-protect/test/unit/explore-node-modules.spec.ts +++ b/packages/snyk-protect/test/unit/explore-node-modules.spec.ts @@ -1,51 +1,49 @@ import * as path from 'path'; import { findPhysicalModules } from '../../src/lib/explore-node-modules'; -describe(findPhysicalModules.name, () => { +describe('findPhysicalModules', () => { it('works with no matching physical modules', () => { - const fixtureFolderRelativePath = '../fixtures/no-matching-paths'; - const fixtureFolder = path.join(__dirname, fixtureFolderRelativePath); + const fixtureFolder = path.resolve( + __dirname, + '../fixtures/no-matching-paths', + ); const found = findPhysicalModules(fixtureFolder, ['lodash']); expect(found).toHaveLength(0); }); it('works with single matching physical module', () => { - const fixtureFolderRelativePath = '../fixtures/single-patchable-module'; - const fixtureFolder = path.join(__dirname, fixtureFolderRelativePath); + const fixtureFolder = path.resolve( + __dirname, + '../fixtures/single-patchable-module', + ); const found = findPhysicalModules(fixtureFolder, ['lodash']); expect(found).toHaveLength(1); const m = found[0]; expect(m.packageName).toBe('lodash'); expect(m.packageVersion).toBe('4.17.15'); expect(m.path).toEqual( - path.join( - __dirname, - fixtureFolderRelativePath, - '/node_modules/nyc/node_modules/lodash', - ), + path.resolve(fixtureFolder, './node_modules/nyc/node_modules/lodash'), ); }); it('works with multiple matching physical modules', () => { - const fixtureFolderRelativePath = '../fixtures/multiple-matching-paths'; - const fixtureFolder = path.join(__dirname, fixtureFolderRelativePath); + const fixtureFolder = path.resolve( + __dirname, + '../fixtures/multiple-matching-paths', + ); const found = findPhysicalModules(fixtureFolder, ['lodash']); expect(found).toHaveLength(2); const m0 = found[0]; expect(m0.packageName).toBe('lodash'); expect(m0.packageVersion).toBe('4.17.15'); expect(m0.path).toEqual( - path.join(__dirname, fixtureFolderRelativePath, '/node_modules/lodash'), + path.resolve(fixtureFolder, './node_modules/lodash'), ); const m1 = found[1]; expect(m1.packageName).toBe('lodash'); expect(m1.packageVersion).toBe('4.17.15'); expect(m1.path).toEqual( - path.join( - __dirname, - fixtureFolderRelativePath, - '/node_modules/nyc/node_modules/lodash', - ), + path.resolve(fixtureFolder, './node_modules/nyc/node_modules/lodash'), ); }); }); diff --git a/packages/snyk-protect/test/unit/patch.spec.ts b/packages/snyk-protect/test/unit/patch.spec.ts index 25ee87e57d..f3749af027 100644 --- a/packages/snyk-protect/test/unit/patch.spec.ts +++ b/packages/snyk-protect/test/unit/patch.spec.ts @@ -5,7 +5,7 @@ import { patchString, } from '../../src/lib/patch'; -describe(patchString.name, () => { +describe('patchString', () => { it('can apply a patch using string', () => { const fixtureFolder = path.join( __dirname, diff --git a/packages/snyk-protect/test/unit/snyk-file.spec.ts b/packages/snyk-protect/test/unit/snyk-file.spec.ts index cf9c8e512e..fbe03a0075 100644 --- a/packages/snyk-protect/test/unit/snyk-file.spec.ts +++ b/packages/snyk-protect/test/unit/snyk-file.spec.ts @@ -1,6 +1,6 @@ import { extractPatchMetadata } from '../../src/lib/snyk-file'; -describe(extractPatchMetadata.name, () => { +describe('extractPatchMetadata', () => { describe('extracts a single direct dependency', () => { it('without quotes on package path', () => { const dotSnykFileContents = ` diff --git a/test/jest/acceptance/cli-json-file-output.spec.ts b/test/jest/acceptance/cli-json-file-output.spec.ts index 6b38fb2732..764422ea98 100644 --- a/test/jest/acceptance/cli-json-file-output.spec.ts +++ b/test/jest/acceptance/cli-json-file-output.spec.ts @@ -91,7 +91,7 @@ describe('test --json-file-output ', () => { '`test --json-file-output produces same JSON output as normal JSON output to stdout`', (done) => { const jsonOutputFilename = `${uuidv4()}.json`; - return exec( + exec( `node ${main} test ${noVulnsProjectPath} --json --json-file-output=${jsonOutputFilename}`, { env: { diff --git a/test/jest/system/snyk-test/python/snyk-test-pyproject.spec.ts b/test/jest/system/snyk-test/python/snyk-test-pyproject.spec.ts index dbdd50747b..59fe41c386 100644 --- a/test/jest/system/snyk-test/python/snyk-test-pyproject.spec.ts +++ b/test/jest/system/snyk-test/python/snyk-test-pyproject.spec.ts @@ -19,7 +19,7 @@ describe('snyk test for python project', () => { describe('no flag is used', () => { describe('project contains pyproject.toml file', () => { - it('should scan poetry vulnerabilities', async (done) => { + it('should scan poetry vulnerabilities', async () => { const fixturePath = join( __dirname, '../../../../acceptance/workspaces', @@ -95,15 +95,13 @@ describe('snyk test for python project', () => { expect(result).toMatchObject({ result: JSON.stringify(expectedResultObject, null, 2), }); - - done(); }); }); }); describe('--all-projects flag is used to scan the project', () => { describe('project does not contain poetry.lock file', () => { - it('should not attempt to scan poetry vulnerabilities', async (done) => { + it('should not attempt to scan poetry vulnerabilities', async () => { const fixturePath = join( __dirname, 'fixtures', @@ -179,13 +177,11 @@ describe('snyk test for python project', () => { expect(result).toMatchObject({ result: JSON.stringify(expectedResultObject, null, 2), }); - - done(); }); }); describe('project does contain poetry.lock file', () => { - it('should scan poetry vulnerabilities', async (done) => { + it('should scan poetry vulnerabilities', async () => { const fixturePath = join( __dirname, 'fixtures', @@ -312,8 +308,6 @@ describe('snyk test for python project', () => { 2, ), }); - - done(); }); }); });