diff --git a/package.json b/package.json index e73edeb31b..3031974482 100644 --- a/package.json +++ b/package.json @@ -10,13 +10,13 @@ "build": "tsc -p tsconfig.build.json", "build:watch": "tsc -p tsconfig.build.json -w", "clean": "node scripts/clean.js", - "pretest": "run-p typecheck lint", + "pretest": "run-s typecheck lint", "test": "run-s -s test:e2e \"test:unit -- {@}\" --", "test:prepare": "npm run test:e2e -- --prepareOnly", "test:e2e": "node scripts/e2e.js", "test:unit": "jest", "test:external": "node scripts/test-external-project.js", - "lint": "run-p lint:ts lint:js", + "lint": "run-s lint:ts lint:js", "lint:js": "eslint . -f stylish", "lint:ts": "tslint -t stylish --project .", "lint:fix": "run-s lint:fix:ts lint:fix:js", diff --git a/src/config/config-set.spec.ts b/src/config/config-set.spec.ts index 759c12dfa2..e08e16c73e 100644 --- a/src/config/config-set.spec.ts +++ b/src/config/config-set.spec.ts @@ -2,6 +2,7 @@ import { testing } from 'bs-logger' import { resolve } from 'path' import ts, { Diagnostic, ModuleKind, ScriptTarget } from 'typescript' +import { version as currentVersion } from '../../package.json' import * as fakers from '../__helpers__/fakers' import { mocked } from '../__helpers__/mocks' import { TsJestGlobalOptions } from '../types' @@ -20,6 +21,7 @@ backports.backportJestConfig.mockImplementation((_, config) => ({ })) const defaultResolve = (path: string) => `resolved:${path}` +const pkgVersion = (pkgName: string) => require(`${pkgName}/package.json`).version || '????' function createConfigSet({ jestConfig, @@ -314,29 +316,23 @@ describe('readTsConfig', () => { describe('versions', () => { describe('without babel', () => { it('should return correct version map', () => { - expect(createConfigSet().versions).toMatchInlineSnapshot(` -Object { - "jest": "23.6.0", - "ts-jest": "23.10.0-beta.6", - "tslib": "1.9.3", - "typescript": "3.0.3", -} -`) + expect(createConfigSet().versions).toEqual({ + jest: pkgVersion('jest'), + 'ts-jest': currentVersion, + typescript: pkgVersion('typescript'), + }) }) }) describe('with babel', () => { it('should return correct version map', () => { - expect(createConfigSet({ tsJestConfig: { babelConfig: {} } }).versions).toMatchInlineSnapshot(` -Object { - "@babel/core": "-", - "babel-core": "6.26.3", - "babel-jest": "23.6.0", - "jest": "23.6.0", - "ts-jest": "23.10.0-beta.6", - "tslib": "1.9.3", - "typescript": "3.0.3", -} -`) + expect(createConfigSet({ tsJestConfig: { babelConfig: {} } }).versions).toEqual({ + '@babel/core': '-', + 'babel-core': pkgVersion('babel-core'), + 'babel-jest': pkgVersion('babel-jest'), + jest: pkgVersion('jest'), + 'ts-jest': currentVersion, + typescript: pkgVersion('typescript'), + }) }) }) }) // versions diff --git a/src/config/config-set.ts b/src/config/config-set.ts index f8dfdd70db..c8774d8f23 100644 --- a/src/config/config-set.ts +++ b/src/config/config-set.ts @@ -234,7 +234,7 @@ export class ConfigSet { @Memoize() get versions(): Record { - const modules = ['jest', this.tsJest.compiler, 'tslib'] + const modules = ['jest', this.tsJest.compiler] if (this.tsJest.babelConfig) { modules.push('@babel/core', 'babel-core', 'babel-jest') } diff --git a/tslint.json b/tslint.json index a32496553b..7669513b00 100644 --- a/tslint.json +++ b/tslint.json @@ -6,6 +6,7 @@ ], "linterOptions": { "exclude": [ + "package.json", "dist/**/*", "**/node_modules/**/*", "e2e/__cases__/**/*"