Skip to content

Commit

Permalink
Merge pull request #1968 from snyk/chore/jest-27
Browse files Browse the repository at this point in the history
chore: upgrade to jest@27
  • Loading branch information
Jahed Ahmed committed Aug 11, 2021
2 parents f1d45a0 + bdb640a commit 338f7a9
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 51 deletions.
4 changes: 0 additions & 4 deletions 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: [
'<rootDir>/test/*.spec.ts',
'<rootDir>/test/iac-unit-tests/*.spec.ts',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -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",
Expand All @@ -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"
},
Expand Down
4 changes: 0 additions & 4 deletions 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'],
};
7 changes: 0 additions & 7 deletions packages/snyk-fix/package.json
Expand Up @@ -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"
Expand Down
4 changes: 0 additions & 4 deletions 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: [
'<rootDir>/test/**/*.spec.ts',
'<rootDir>\\test\\**\\*.spec.ts', // for Windows
Expand Down
34 changes: 16 additions & 18 deletions 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'),
);
});
});
2 changes: 1 addition & 1 deletion packages/snyk-protect/test/unit/patch.spec.ts
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion 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 = `
Expand Down
2 changes: 1 addition & 1 deletion test/jest/acceptance/cli-json-file-output.spec.ts
Expand Up @@ -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: {
Expand Down
12 changes: 3 additions & 9 deletions test/jest/system/snyk-test/python/snyk-test-pyproject.spec.ts
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -312,8 +308,6 @@ describe('snyk test for python project', () => {
2,
),
});

done();
});
});
});
Expand Down

0 comments on commit 338f7a9

Please sign in to comment.