@@ -2,7 +2,7 @@ import { testing } from 'bs-logger'
|
2 | 2 | import { resolve } from 'path'
|
3 | 3 | import ts, { Diagnostic, ModuleKind, ScriptTarget } from 'typescript'
|
4 | 4 |
|
5 |
| -import { version as currentVersion } from '../../package.json' |
| 5 | +import * as _myModule from '..' |
6 | 6 | import * as fakers from '../__helpers__/fakers'
|
7 | 7 | import { logTargetMock, mocked } from '../__helpers__/mocks'
|
8 | 8 | import { TsJestGlobalOptions } from '../types'
|
@@ -12,8 +12,10 @@ import { normalizeSlashes } from '../util/normalize-slashes'
|
12 | 12 | import { ConfigSet, IGNORE_DIAGNOSTIC_CODES, MATCH_NOTHING } from './config-set'
|
13 | 13 |
|
14 | 14 | jest.mock('../util/backports')
|
| 15 | +jest.mock('../index') |
15 | 16 |
|
16 | 17 | const backports = mocked(_backports)
|
| 18 | +const myModule = mocked(_myModule) |
17 | 19 |
|
18 | 20 | backports.backportJestConfig.mockImplementation((_, config) => ({
|
19 | 21 | ...config,
|
@@ -385,7 +387,7 @@ describe('versions', () => {
|
385 | 387 | it('should return correct version map', () => {
|
386 | 388 | expect(createConfigSet().versions).toEqual({
|
387 | 389 | jest: pkgVersion('jest'),
|
388 |
| -'ts-jest': currentVersion, |
| 390 | +'ts-jest': myModule.version, |
389 | 391 | typescript: pkgVersion('typescript'),
|
390 | 392 | })
|
391 | 393 | })
|
@@ -397,13 +399,19 @@ describe('versions', () => {
|
397 | 399 | 'babel-core': pkgVersion('babel-core'),
|
398 | 400 | 'babel-jest': pkgVersion('babel-jest'),
|
399 | 401 | jest: pkgVersion('jest'),
|
400 |
| -'ts-jest': currentVersion, |
| 402 | +'ts-jest': myModule.version, |
401 | 403 | typescript: pkgVersion('typescript'),
|
402 | 404 | })
|
403 | 405 | })
|
404 | 406 | })
|
405 | 407 | }) // versions
|
406 | 408 |
|
| 409 | +describe('tsJestDigest', () => { |
| 410 | +it('should be the package digest', () => { |
| 411 | +expect(createConfigSet().tsJestDigest).toBe(myModule.digest) |
| 412 | +}) |
| 413 | +}) // tsJestDigest |
| 414 | + |
407 | 415 | describe('tsconfig', () => {
|
408 | 416 | it('should return input tsconfig', () => {
|
409 | 417 | const cs = createConfigSet({ tsJestConfig: { tsConfig: { target: 'ES6' } } as any })
|
@@ -468,8 +476,9 @@ describe('cacheKey', () => {
|
468 | 476 | const val = cs.jsonValue.value
|
469 | 477 | delete val.versions
|
470 | 478 | cs.jsonValue.value = val
|
| 479 | +// digest is mocked in src/__mocks__/index.ts |
471 | 480 | 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}}"`, |
473 | 482 | )
|
474 | 483 | })
|
475 | 484 | }) // cacheKey
|
@@ -479,13 +488,15 @@ describe('jsonValue', () => {
|
479 | 488 | const cs = createConfigSet({ tsJestConfig: { tsConfig: false } as any })
|
480 | 489 | const val = cs.jsonValue.valueOf()
|
481 | 490 | 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 |
483 | 492 | expect(val.versions).toEqual(cs.versions)
|
484 | 493 | delete val.versions
|
485 | 494 |
|
| 495 | +// digest is mocked in src/__mocks__/index.ts |
486 | 496 | expect(val).toMatchInlineSnapshot(`
|
487 | 497 | Object {
|
488 | 498 | "babel": undefined,
|
| 499 | +"digest": "a0d51ca854194df8191d0e65c0ca4730f510f332", |
489 | 500 | "jest": Object {
|
490 | 501 | "__backported": true,
|
491 | 502 | "globals": Object {},
|
@@ -511,7 +522,16 @@ Object {
|
511 | 522 | "tsConfig": undefined,
|
512 | 523 | },
|
513 | 524 | "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, |
515 | 535 | },
|
516 | 536 | }
|
517 | 537 | `)
|
|
0 commit comments