@@ -2,7 +2,7 @@ import { testing } from 'bs-logger'
22import { resolve } from 'path'
33import ts , { Diagnostic , ModuleKind , ScriptTarget } from 'typescript'
44
5- import { version as currentVersion } from '../../package.json '
5+ import * as _myModule from '..'
66import * as fakers from '../__helpers__/fakers'
77import { logTargetMock , mocked } from '../__helpers__/mocks'
88import { TsJestGlobalOptions } from '../types'
@@ -12,8 +12,10 @@ import { normalizeSlashes } from '../util/normalize-slashes'
1212import { ConfigSet , IGNORE_DIAGNOSTIC_CODES , MATCH_NOTHING } from './config-set'
1313
1414jest . mock ( '../util/backports' )
15+ jest . mock ( '../index' )
1516
1617const backports = mocked ( _backports )
18+ const myModule = mocked ( _myModule )
1719
1820backports . backportJestConfig . mockImplementation ( ( _ , config ) => ( {
1921 ...config ,
@@ -385,7 +387,7 @@ describe('versions', () => {
385387 it ( 'should return correct version map' , ( ) => {
386388 expect ( createConfigSet ( ) . versions ) . toEqual ( {
387389 jest : pkgVersion ( 'jest' ) ,
388- 'ts-jest' : currentVersion ,
390+ 'ts-jest' : myModule . version ,
389391 typescript : pkgVersion ( 'typescript' ) ,
390392 } )
391393 } )
@@ -397,13 +399,19 @@ describe('versions', () => {
397399 'babel-core' : pkgVersion ( 'babel-core' ) ,
398400 'babel-jest' : pkgVersion ( 'babel-jest' ) ,
399401 jest : pkgVersion ( 'jest' ) ,
400- 'ts-jest' : currentVersion ,
402+ 'ts-jest' : myModule . version ,
401403 typescript : pkgVersion ( 'typescript' ) ,
402404 } )
403405 } )
404406 } )
405407} ) // versions
406408
409+ describe ( 'tsJestDigest' , ( ) => {
410+ it ( 'should be the package digest' , ( ) => {
411+ expect ( createConfigSet ( ) . tsJestDigest ) . toBe ( myModule . digest )
412+ } )
413+ } ) // tsJestDigest
414+
407415describe ( 'tsconfig' , ( ) => {
408416 it ( 'should return input tsconfig' , ( ) => {
409417 const cs = createConfigSet ( { tsJestConfig : { tsConfig : { target : 'ES6' } } as any } )
@@ -468,8 +476,9 @@ describe('cacheKey', () => {
468476 const val = cs . jsonValue . value
469477 delete val . versions
470478 cs . jsonValue . value = val
479+ // digest is mocked in src/__mocks__/index.ts
471480 expect ( cs . cacheKey ) . toMatchInlineSnapshot (
472- `"{\\"jest\\":{\\"__backported\\":true,\\"globals\\":{}},\\"transformers\\":[\\"hoisting-jest-mock@1\\"],\\"tsJest\\":{\\"compiler\\":\\"typescript\\",\\"diagnostics\\":{\\"ignoreCodes\\":[6059,18002,18003],\\"pretty\\":true,\\"throws\\":true},\\"isolatedModules\\":false,\\"transformers\\":[]},\\"tsconfig\\":{\\"compilerOptions \\":{} }}"` ,
481+ `"{\\"digest\\":\\"a0d51ca854194df8191d0e65c0ca4730f510f332\\",\\" jest\\":{\\"__backported\\":true,\\"globals\\":{}},\\"transformers\\":[\\"hoisting-jest-mock@1\\"],\\"tsJest\\":{\\"compiler\\":\\"typescript\\",\\"diagnostics\\":{\\"ignoreCodes\\":[6059,18002,18003],\\"pretty\\":true,\\"throws\\":true},\\"isolatedModules\\":false,\\"transformers\\":[]},\\"tsconfig\\":{\\"declaration \\":false,\\"inlineSourceMap\\":false,\\"inlineSources\\":true,\\"module\\":1,\\"noEmit\\":false,\\"outDir\\":\\"$$ts-jest$$\\",\\"removeComments\\":false,\\"sourceMap\\":true,\\"target\\":1 }}"` ,
473482 )
474483 } )
475484} ) // cacheKey
@@ -479,13 +488,15 @@ describe('jsonValue', () => {
479488 const cs = createConfigSet ( { tsJestConfig : { tsConfig : false } as any } )
480489 const val = cs . jsonValue . valueOf ( )
481490 expect ( cs . toJSON ( ) ) . toEqual ( val )
482- // it will change each time we upgrade and we tested those in the `version` block
491+ // it will change each time we upgrade – we tested those in the `version` block
483492 expect ( val . versions ) . toEqual ( cs . versions )
484493 delete val . versions
485494
495+ // digest is mocked in src/__mocks__/index.ts
486496 expect ( val ) . toMatchInlineSnapshot ( `
487497Object {
488498 "babel": undefined,
499+ "digest": "a0d51ca854194df8191d0e65c0ca4730f510f332",
489500 "jest": Object {
490501 "__backported": true,
491502 "globals": Object {},
@@ -511,7 +522,16 @@ Object {
511522 "tsConfig": undefined,
512523 },
513524 "tsconfig": Object {
514- "compilerOptions": Object {},
525+ "configFilePath": undefined,
526+ "declaration": false,
527+ "inlineSourceMap": false,
528+ "inlineSources": true,
529+ "module": 1,
530+ "noEmit": false,
531+ "outDir": "$$ts-jest$$",
532+ "removeComments": false,
533+ "sourceMap": true,
534+ "target": 1,
515535 },
516536}
517537` )
0 commit comments