ts-jest 25.2.1 → 25.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.ts-jest-digest CHANGED
@@ -1 +1 @@
1
- 6982d3f1883cd9adc2334b36b70c6625ec327569
1
+ 3d1d5533ca7904f38987f652b68e127201c3a7b3
package/CHANGELOG.md CHANGED
@@ -1,10 +1,39 @@
1
+ <a name="25.3.0"></a>
2
+ # [25.3.0](https://github.com/kulshekhar/ts-jest/compare/25.2.1...25.3.0) (2020-03-30)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * add jest-config to dependencies list ([6d9e0d8](https://github.com/kulshekhar/ts-jest/commit/6d9e0d8))
8
+ * always do type check for all files provided to ts-jest transformer ([#1450](https://github.com/kulshekhar/ts-jest/issues/1450)) ([107e062](https://github.com/kulshekhar/ts-jest/commit/107e062))
9
+ * **docs:** correct changelog, correct version in package.json ([#1406](https://github.com/kulshekhar/ts-jest/issues/1406)) ([542e181](https://github.com/kulshekhar/ts-jest/commit/542e181))
10
+
11
+
12
+ ### Chores
13
+
14
+ * **config:** improve diagnostics message ([#1444](https://github.com/kulshekhar/ts-jest/issues/1444)) ([96cd9b3](https://github.com/kulshekhar/ts-jest/commit/96cd9b3))
15
+
16
+
17
+ ### Features
18
+
19
+ * **compiler:** expose internal ts `Program` via ConfigSet `TsCompiler` ([#1433](https://github.com/kulshekhar/ts-jest/issues/1433)) ([7153246](https://github.com/kulshekhar/ts-jest/commit/7153246))
20
+ * **config:** add incremental option ([#1418](https://github.com/kulshekhar/ts-jest/issues/1418)) ([5a69bce](https://github.com/kulshekhar/ts-jest/commit/5a69bce))
21
+
22
+
23
+ ### BREAKING CHANGES
24
+
25
+ * **config:** This will affect to any snapshots or assertion against diagnostics messages
26
+
27
+
28
+
1
29
  <a name="25.2.1"></a>
2
- ## [25.2.1](https://github.com/kulshekhar/ts-jest/compare/v25.2.0...v25.2.1) (2020-02-19)
30
+ ## [25.2.1](https://github.com/kulshekhar/ts-jest/compare/v25.2.0...25.2.1) (2020-02-21)
3
31
 
4
32
 
5
33
  ### Bug Fixes
6
34
 
7
35
  * **compiler:** allow transformation of typescript files in node_modules ([#1385](https://github.com/kulshekhar/ts-jest/issues/1385)) ([814405e](https://github.com/kulshekhar/ts-jest/commit/814405e))
36
+ * **docs:** fixing slack link and some minor typos in documenation ([#1404](https://github.com/kulshekhar/ts-jest/issues/1404)) ([3e2e008](https://github.com/kulshekhar/ts-jest/commit/3e2e008))
8
37
  * **transformer:** add deepUnmock to hoist method list ([#1372](https://github.com/kulshekhar/ts-jest/issues/1372)) ([0fbbc00](https://github.com/kulshekhar/ts-jest/commit/0fbbc00))
9
38
  * **util:** use resolve package typescript package in yarn workspaces ([#1377](https://github.com/kulshekhar/ts-jest/issues/1377)) ([a63808c](https://github.com/kulshekhar/ts-jest/commit/a63808c))
10
39
 
@@ -68,9 +97,9 @@
68
97
 
69
98
  ### Bug Fixes
70
99
 
71
- * typescript serviceHost cache miss on Windows operating systems ([26ee731](https://github.com/kulshekhar/ts-jest/commit/26ee731))
72
100
  * **compiler:** pass filename to sha function instead of file extension ([ac1ac97](https://github.com/kulshekhar/ts-jest/commit/ac1ac97))
73
101
  * **transformers:** hoist jest.enableAutomock and jest.disableAutomock ([ac50bc3](https://github.com/kulshekhar/ts-jest/commit/ac50bc3))
102
+ * typescript serviceHost cache miss on Windows operating systems ([26ee731](https://github.com/kulshekhar/ts-jest/commit/26ee731))
74
103
 
75
104
 
76
105
 
@@ -80,9 +109,9 @@
80
109
 
81
110
  ### Bug Fixes
82
111
 
112
+ * **perf:** add cache for fs calls ([#908](https://github.com/kulshekhar/ts-jest/issues/908)) ([3dada81](https://github.com/kulshekhar/ts-jest/commit/3dada81))
83
113
  * [#825](https://github.com/kulshekhar/ts-jest/issues/825) handle symlinked modules (ala pnpm) correctly ([e190b23](https://github.com/kulshekhar/ts-jest/commit/e190b23))
84
114
  * handle tsBuildInfoFile option ([f9583e9](https://github.com/kulshekhar/ts-jest/commit/f9583e9)), closes [#1095](https://github.com/kulshekhar/ts-jest/issues/1095)
85
- * **perf:** add cache for fs calls ([#908](https://github.com/kulshekhar/ts-jest/issues/908)) ([3dada81](https://github.com/kulshekhar/ts-jest/commit/3dada81))
86
115
  * **types:** unforce esModuleInterop in tsconfig.json ([c2d39b6](https://github.com/kulshekhar/ts-jest/commit/c2d39b6))
87
116
 
88
117
 
@@ -294,6 +323,10 @@
294
323
 
295
324
  ### Bug Fixes
296
325
 
326
+ * **ci:** can't use runInBand for e2e: cache collision ([db650f4](https://github.com/kulshekhar/ts-jest/commit/db650f4))
327
+ * **ci:** do not run e2e sub-tests in band ([18ad865](https://github.com/kulshekhar/ts-jest/commit/18ad865))
328
+ * **ci:** ensure npm is present with ci ([edb6eda](https://github.com/kulshekhar/ts-jest/commit/edb6eda))
329
+ * **logger:** removes cyclic imports ([5ef980f](https://github.com/kulshekhar/ts-jest/commit/5ef980f))
297
330
  * babel-config + adds test ([12146c3](https://github.com/kulshekhar/ts-jest/commit/12146c3))
298
331
  * fixes js style to be node < 10 compatible ([83d7517](https://github.com/kulshekhar/ts-jest/commit/83d7517))
299
332
  * hoisting per level + memoize fix ([31847b0](https://github.com/kulshekhar/ts-jest/commit/31847b0))
@@ -301,53 +334,49 @@
301
334
  * makes node 6 happy ([f6f82b8](https://github.com/kulshekhar/ts-jest/commit/f6f82b8))
302
335
  * makes node6 happy ([f170285](https://github.com/kulshekhar/ts-jest/commit/f170285))
303
336
  * makes window happy ([36fbebe](https://github.com/kulshekhar/ts-jest/commit/36fbebe))
304
- * **ci:** can't use runInBand for e2e: cache collision ([db650f4](https://github.com/kulshekhar/ts-jest/commit/db650f4))
305
- * **ci:** do not run e2e sub-tests in band ([18ad865](https://github.com/kulshekhar/ts-jest/commit/18ad865))
306
- * **ci:** ensure npm is present with ci ([edb6eda](https://github.com/kulshekhar/ts-jest/commit/edb6eda))
307
- * **logger:** removes cyclic imports ([5ef980f](https://github.com/kulshekhar/ts-jest/commit/5ef980f))
308
- * **tests:** detect npm version to use or not ci ([683a1e5](https://github.com/kulshekhar/ts-jest/commit/683a1e5))
309
337
  * node 6 unhappy again... ([703ad0b](https://github.com/kulshekhar/ts-jest/commit/703ad0b))
310
- * **tests:** CI fixes ([34a41ea](https://github.com/kulshekhar/ts-jest/commit/34a41ea))
311
- * **tests:** do not use babel in our tests + new API for simple ([3e4de3e](https://github.com/kulshekhar/ts-jest/commit/3e4de3e))
312
338
  * normalizes bundle hash on any node version ([ce7afaf](https://github.com/kulshekhar/ts-jest/commit/ce7afaf))
313
339
  * npm coming with node 6 doesn't talk `ci` ([b87198d](https://github.com/kulshekhar/ts-jest/commit/b87198d))
314
340
  * source maps ([89a30c9](https://github.com/kulshekhar/ts-jest/commit/89a30c9))
315
341
  * typos + node 6 compat ([0ed1587](https://github.com/kulshekhar/ts-jest/commit/0ed1587))
316
- * **tests:** more sanitizing for windows compat ([faae274](https://github.com/kulshekhar/ts-jest/commit/faae274))
317
342
  * updates templates ([f2e1da2](https://github.com/kulshekhar/ts-jest/commit/f2e1da2))
318
343
  * uses cross-platform spawn + fix pkg versions ([ac1599c](https://github.com/kulshekhar/ts-jest/commit/ac1599c))
319
344
  * we are not writing files, use normalized EOL ([47fff43](https://github.com/kulshekhar/ts-jest/commit/47fff43))
345
+ * **tests:** CI fixes ([34a41ea](https://github.com/kulshekhar/ts-jest/commit/34a41ea))
346
+ * **tests:** detect npm version to use or not ci ([683a1e5](https://github.com/kulshekhar/ts-jest/commit/683a1e5))
347
+ * **tests:** do not use babel in our tests + new API for simple ([3e4de3e](https://github.com/kulshekhar/ts-jest/commit/3e4de3e))
348
+ * **tests:** more sanitizing for windows compat ([faae274](https://github.com/kulshekhar/ts-jest/commit/faae274))
320
349
 
321
350
 
322
351
  ### Features
323
352
 
324
- * diagnostics, different compilers, ... ([f26ebf0](https://github.com/kulshekhar/ts-jest/commit/f26ebf0))
325
353
  * **config:** adds a helper to build moduleNameMapper from paths ([7b8598e](https://github.com/kulshekhar/ts-jest/commit/7b8598e)), closes [#364](https://github.com/kulshekhar/ts-jest/issues/364)
326
354
  * **logging:** improves log messages + tests ([5d03c4d](https://github.com/kulshekhar/ts-jest/commit/5d03c4d))
327
- * jest preset ([beb50b5](https://github.com/kulshekhar/ts-jest/commit/beb50b5))
328
- * **test:** jest serializers ([dfa9c0f](https://github.com/kulshekhar/ts-jest/commit/dfa9c0f))
329
355
  * adds logging + better hashing ([4322701](https://github.com/kulshekhar/ts-jest/commit/4322701))
330
- * **tests:** more test tools + adds test related to debuggin issues ([8dcafca](https://github.com/kulshekhar/ts-jest/commit/8dcafca))
331
356
  * allow env var to add diagnostic codes to ignore ([777edf5](https://github.com/kulshekhar/ts-jest/commit/777edf5))
332
357
  * cache key + tests ([bd55448](https://github.com/kulshekhar/ts-jest/commit/bd55448))
358
+ * diagnostics, different compilers, ... ([f26ebf0](https://github.com/kulshekhar/ts-jest/commit/f26ebf0))
333
359
  * directly writes to stdio so jest does not swallow ([6a7f01f](https://github.com/kulshekhar/ts-jest/commit/6a7f01f))
334
360
  * handles stringifyContentPathRegex ([3fcb4bd](https://github.com/kulshekhar/ts-jest/commit/3fcb4bd))
335
361
  * hoisting + tests + many other things ([6186e84](https://github.com/kulshekhar/ts-jest/commit/6186e84))
336
362
  * io serializer + other test utils ([d03e0e7](https://github.com/kulshekhar/ts-jest/commit/d03e0e7))
363
+ * jest preset ([beb50b5](https://github.com/kulshekhar/ts-jest/commit/beb50b5))
337
364
  * warn about unsupported versions ([1103071](https://github.com/kulshekhar/ts-jest/commit/1103071))
365
+ * **test:** jest serializers ([dfa9c0f](https://github.com/kulshekhar/ts-jest/commit/dfa9c0f))
366
+ * **tests:** more test tools + adds test related to debuggin issues ([8dcafca](https://github.com/kulshekhar/ts-jest/commit/8dcafca))
338
367
 
339
368
 
340
369
  ### Performance Improvements
341
370
 
342
- * detects changes in templates and bundle ([2a3da21](https://github.com/kulshekhar/ts-jest/commit/2a3da21))
343
371
  * **babel:** uses babel-jest cache key as part of ours ([f51c4a7](https://github.com/kulshekhar/ts-jest/commit/f51c4a7))
372
+ * **cache:** share config-sets for parallel test running ([090ca7b](https://github.com/kulshekhar/ts-jest/commit/090ca7b))
373
+ * **tests:** run e2e tests in band ([b3e94ff](https://github.com/kulshekhar/ts-jest/commit/b3e94ff))
374
+ * detects changes in templates and bundle ([2a3da21](https://github.com/kulshekhar/ts-jest/commit/2a3da21))
344
375
  * do not type check if fileName doesn't match ([cc45adc](https://github.com/kulshekhar/ts-jest/commit/cc45adc))
345
376
  * faster tests ([37a0187](https://github.com/kulshekhar/ts-jest/commit/37a0187))
346
377
  * improves speed of local test after 1st run ([cc04021](https://github.com/kulshekhar/ts-jest/commit/cc04021))
347
378
  * more cleaning ([c48f7b8](https://github.com/kulshekhar/ts-jest/commit/c48f7b8))
348
379
  * trying to improve travis-ci conf ([e4b4d95](https://github.com/kulshekhar/ts-jest/commit/e4b4d95))
349
- * **cache:** share config-sets for parallel test running ([090ca7b](https://github.com/kulshekhar/ts-jest/commit/090ca7b))
350
- * **tests:** run e2e tests in band ([b3e94ff](https://github.com/kulshekhar/ts-jest/commit/b3e94ff))
351
380
 
352
381
 
353
382
 
@@ -357,21 +386,21 @@
357
386
 
358
387
  ### Bug Fixes
359
388
 
360
- * **html:** correctly transforms html source when needed ([9a2d74f](https://github.com/kulshekhar/ts-jest/commit/9a2d74f))
361
- * **lint:** fixes tslint script & lint issues ([60ab36e](https://github.com/kulshekhar/ts-jest/commit/60ab36e))
362
- * **package:** update fs-extra to version 6.0.1 ([7e73536](https://github.com/kulshekhar/ts-jest/commit/7e73536))
363
389
  * allow (but deprecate) use of old preprocessor.js ([a65079f](https://github.com/kulshekhar/ts-jest/commit/a65079f))
364
390
  * big refactor + fixes (mainly cache key + coverage) ([e46caae](https://github.com/kulshekhar/ts-jest/commit/e46caae))
365
391
  * fixes coverage and tests ([09500c2](https://github.com/kulshekhar/ts-jest/commit/09500c2))
366
392
  * gracefully load [@babel](https://github.com/babel)/core or babel-core ([98b2410](https://github.com/kulshekhar/ts-jest/commit/98b2410))
367
393
  * hack for babel < 6 so that breakpoints do work ([90c74ef](https://github.com/kulshekhar/ts-jest/commit/90c74ef)), closes [#627](https://github.com/kulshekhar/ts-jest/issues/627)
368
- * **package:** update pkg-dir to version 3.0.0 ([3fb8f9f](https://github.com/kulshekhar/ts-jest/commit/3fb8f9f))
369
- * **package:** update yargs to version 12.0.1 ([390ffcd](https://github.com/kulshekhar/ts-jest/commit/390ffcd))
370
394
  * resolves correctly config file path (fix [#636](https://github.com/kulshekhar/ts-jest/issues/636)) ([5ab100c](https://github.com/kulshekhar/ts-jest/commit/5ab100c))
371
395
  * test rootDir to handle preset-angular ([8a6a8f7](https://github.com/kulshekhar/ts-jest/commit/8a6a8f7))
372
- * Typo in utils.ts ([#534](https://github.com/kulshekhar/ts-jest/issues/534)) ([a650260](https://github.com/kulshekhar/ts-jest/commit/a650260))
373
- * **source-maps:** fix source maps options/calls ([76e27c1](https://github.com/kulshekhar/ts-jest/commit/76e27c1))
374
396
  * wrong error message ([c955083](https://github.com/kulshekhar/ts-jest/commit/c955083))
397
+ * **html:** correctly transforms html source when needed ([9a2d74f](https://github.com/kulshekhar/ts-jest/commit/9a2d74f))
398
+ * **lint:** fixes tslint script & lint issues ([60ab36e](https://github.com/kulshekhar/ts-jest/commit/60ab36e))
399
+ * **package:** update fs-extra to version 6.0.1 ([7e73536](https://github.com/kulshekhar/ts-jest/commit/7e73536))
400
+ * **package:** update pkg-dir to version 3.0.0 ([3fb8f9f](https://github.com/kulshekhar/ts-jest/commit/3fb8f9f))
401
+ * **package:** update yargs to version 12.0.1 ([390ffcd](https://github.com/kulshekhar/ts-jest/commit/390ffcd))
402
+ * **source-maps:** fix source maps options/calls ([76e27c1](https://github.com/kulshekhar/ts-jest/commit/76e27c1))
403
+ * Typo in utils.ts ([#534](https://github.com/kulshekhar/ts-jest/issues/534)) ([a650260](https://github.com/kulshekhar/ts-jest/commit/a650260))
375
404
 
376
405
 
377
406
  ### Performance Improvements
@@ -392,9 +421,9 @@
392
421
  ### Bug Fixes
393
422
 
394
423
  * **package:** update source-map-support to version 0.5.0 ([f0aab12](https://github.com/kulshekhar/ts-jest/commit/f0aab12))
395
- * add startDir to if-clause ([eed5311](https://github.com/kulshekhar/ts-jest/commit/eed5311))
396
424
  * **package:** update yargs to version 10.0.3 ([5cdf969](https://github.com/kulshekhar/ts-jest/commit/5cdf969))
397
425
  * **package:** update yargs to version 11.0.0 ([7e9ce40](https://github.com/kulshekhar/ts-jest/commit/7e9ce40))
426
+ * add startDir to if-clause ([eed5311](https://github.com/kulshekhar/ts-jest/commit/eed5311))
398
427
  * **package:** update yargs to version 9.0.1 ([#326](https://github.com/kulshekhar/ts-jest/issues/326)) ([8bf9924](https://github.com/kulshekhar/ts-jest/commit/8bf9924))
399
428
 
400
429
 
@@ -450,10 +479,10 @@
450
479
 
451
480
  ### Bug Fixes
452
481
 
453
- * **package:** update fs-extra to version 3.0.0 ([906be12](https://github.com/kulshekhar/ts-jest/commit/906be12))
454
- * **package:** update yargs to version 8.0.1 ([0b2ea98](https://github.com/kulshekhar/ts-jest/commit/0b2ea98))
455
482
  * peer dependency against Typescript 2.x ([cb08128](https://github.com/kulshekhar/ts-jest/commit/cb08128))
456
483
  * remove outDir when collecting coverage ([c076956](https://github.com/kulshekhar/ts-jest/commit/c076956))
484
+ * **package:** update fs-extra to version 3.0.0 ([906be12](https://github.com/kulshekhar/ts-jest/commit/906be12))
485
+ * **package:** update yargs to version 8.0.1 ([0b2ea98](https://github.com/kulshekhar/ts-jest/commit/0b2ea98))
457
486
 
458
487
 
459
488
  ### Features
package/CONTRIBUTING.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Contributing
2
2
 
3
- When contributing to this repository, please first discuss the change you wish to make via [slack](https://bit.ly/ts-jest-slack) or [issue](https://github.com/kulshekhar/ts-jest/issues) with the owners of this repository before making a change.
3
+ When contributing to this repository, please first discuss the change you wish to make via [slack](https://bit.ly/3bRHFPQ) or [issue](https://github.com/kulshekhar/ts-jest/issues) with the owners of this repository before making a change.
4
4
 
5
5
  Please note we have a code of conduct, please follow it in all your interactions with the project.
6
6
 
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ts-jest [![npm version](https://badge.fury.io/js/ts-jest.svg)](https://badge.fury.io/js/ts-jest) [![NPM downloads](https://img.shields.io/npm/dm/ts-jest.svg?style=flat)](https://npmjs.org/package/ts-jest) [![Known Vulnerabilities](https://snyk.io/test/github/kulshekhar/ts-jest/badge.svg)](https://snyk.io/test/github/kulshekhar/ts-jest) [![Coverage Status](https://coveralls.io/repos/github/kulshekhar/ts-jest/badge.svg?branch=master)](https://coveralls.io/github/kulshekhar/ts-jest?branch=master) [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=kulshekhar/ts-jest)](https://dependabot.com) [![Build Status for linux](https://travis-ci.org/kulshekhar/ts-jest.svg?branch=master)](https://travis-ci.org/kulshekhar/ts-jest) [![Build Status for Windows](https://ci.appveyor.com/api/projects/status/g8tt9qd7usv0tolb/branch/master?svg=true)](https://ci.appveyor.com/project/kulshekhar/ts-jest/branch/master)
1
+ # ts-jest [![npm version](https://badge.fury.io/js/ts-jest.svg)](https://badge.fury.io/js/ts-jest) [![NPM downloads](https://img.shields.io/npm/dm/ts-jest.svg?style=flat)](https://npmjs.org/package/ts-jest) [![Known Vulnerabilities](https://snyk.io/test/github/kulshekhar/ts-jest/badge.svg)](https://snyk.io/test/github/kulshekhar/ts-jest) [![Coverage Status](https://coveralls.io/repos/github/kulshekhar/ts-jest/badge.svg?branch=master)](https://coveralls.io/github/kulshekhar/ts-jest?branch=master) [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=kulshekhar/ts-jest)](https://dependabot.com) [![Build Status](https://travis-ci.com/kulshekhar/ts-jest.svg?branch=master)](https://travis-ci.com/kulshekhar/ts-jest)
2
2
 
3
3
  <img src="./icon.png" align="right" title="ts-jest Logo" width="128" height="128">
4
4
 
@@ -13,11 +13,9 @@ It supports all features of TypeScript including type-checking. [Read more about
13
13
 
14
14
  [<img src="./docs/assets/img/documentation.png" align="left" height="24"> View the online documentation (usage & technical)](https://kulshekhar.github.io/ts-jest)
15
15
 
16
- [<img src="./docs/assets/img/slack.png" align="left" height="24"> Ask for some help in the `ts-jest` community of Slack](https://join.slack.com/t/ts-jest/shared_invite/enQtNDE1ODQ0OTEzMTczLWI5NTQ4ZmEzOTYxYzM2NjhiZDM2ZTI3MGYyYjA2Y2E1YTMxMjUyYTcxNTlmNjAyZTc2Nzk4YTRmZmRhYmZmYTg)
16
+ [<img src="./docs/assets/img/slack.png" align="left" height="24"> Ask for some help in the `ts-jest` community of Slack](https://bit.ly/3bRHFPQ)
17
17
 
18
- <!--
19
- [<img src="./docs/assets/img/troubleshooting.png" align="left" height="24"> Before reporting any issue, be sure to check the troubleshooting page](https://kulshekhar.github.io/ts-jest/user/troubleshooting)
20
- -->
18
+ [<img src="./docs/assets/img/troubleshooting.png" align="left" height="24"> Before reporting any issue, be sure to check the troubleshooting page](TROUBLESHOOTING.md)
21
19
 
22
20
  [<img src="./docs/assets/img/pull-request.png" align="left" height="24"> We're looking for collaborators! Want to help improve `ts-jest`?](https://github.com/kulshekhar/ts-jest/issues/223)
23
21
 
@@ -0,0 +1,41 @@
1
+ # Troubleshooting
2
+
3
+ ## Running ts-jest on CI tools
4
+
5
+ ### PROBLEM
6
+
7
+ Cannot find module "" from ""
8
+
9
+ ### SOLUTION
10
+
11
+ - Check if `rootDir` is referenced correctly. If not add this on your existing jest configuration.
12
+
13
+ ```javascipt
14
+ module.exports = {
15
+ ...
16
+ roots: ["<rootDir>"]
17
+ }
18
+ ```
19
+
20
+ - Check if module directories are included on your jest configuration. If not add this on your existing jest configuration.
21
+
22
+ ```javascipt
23
+ module.exports = {
24
+ ...
25
+ moduleDirectories: ["node_modules","<module-directory>"],
26
+ modulePaths: ["<path-of-module>"],
27
+ }
28
+ ```
29
+
30
+ - Check if module name is properly mapped and can be referenced by jest. If not, you can define moduleNameMapper for your jest configuration.
31
+
32
+ ```javascipt
33
+ module.exports = {
34
+ ...
35
+ moduleNameMapper: {
36
+ "<import-path>": "<rootDir>/<real-physical-path>",
37
+ },
38
+ }
39
+ ```
40
+
41
+ - Check github folder names if its identical to you local folder names. Sometimes github never updates your folder names even if you rename it locally. If this happens rename your folders via github or use this command `git mv <source> <destination>` and commit changes.
@@ -87,7 +87,7 @@ exports.run = function (args) { return __awaiter(void 0, void 0, void 0, functio
87
87
  migratedConfig = backports_1.backportJestConfig(nullLogger, actualConfig);
88
88
  if (!migratedConfig.preset && args.jestPreset) {
89
89
  if (args.js) {
90
- presetName = args.js === 'babel' ? presets_1.JestPresetNames.jsWIthBabel : presets_1.JestPresetNames.jsWithTs;
90
+ presetName = args.js === 'babel' ? "ts-jest/presets/js-with-babel" : "ts-jest/presets/js-with-ts";
91
91
  }
92
92
  else {
93
93
  jsTransformers = Object.keys(migratedConfig.transform || {}).reduce(function (list, pattern) {
@@ -104,16 +104,16 @@ exports.run = function (args) { return __awaiter(void 0, void 0, void 0, functio
104
104
  jsWithTs = jsTransformers.includes('ts-jest');
105
105
  jsWithBabel = jsTransformers.includes('babel-jest');
106
106
  if (jsWithBabel && !jsWithTs) {
107
- presetName = presets_1.JestPresetNames.jsWIthBabel;
107
+ presetName = "ts-jest/presets/js-with-babel";
108
108
  }
109
109
  else if (jsWithTs && !jsWithBabel) {
110
- presetName = presets_1.JestPresetNames.jsWithTs;
110
+ presetName = "ts-jest/presets/js-with-ts";
111
111
  }
112
112
  else {
113
- presetName = presets_1.JestPresetNames.default;
113
+ presetName = "ts-jest/presets/default";
114
114
  }
115
115
  }
116
- presetName = presetName || presets_1.JestPresetNames.default;
116
+ presetName = presetName || "ts-jest/presets/default";
117
117
  preset = presets_1.allPresets[presetName];
118
118
  footNotes.push("Detected preset '" + preset.label + "' as the best matching preset for your configuration.\nVisit https://kulshekhar.github.io/ts-jest/user/config/#jest-preset for more information about presets.\n");
119
119
  }
@@ -201,7 +201,7 @@ function cleanupConfig(config) {
201
201
  if (config.testMatch.length === 0)
202
202
  delete config.testMatch;
203
203
  }
204
- if (config.preset === presets_1.JestPresetNames.default)
204
+ if (config.preset === "ts-jest/presets/default")
205
205
  config.preset = presets_1.defaults.name;
206
206
  }
207
207
  function dedupSort(arr) {
@@ -1,11 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var JestPresetNames;
4
- (function (JestPresetNames) {
5
- JestPresetNames["default"] = "ts-jest/presets/default";
6
- JestPresetNames["jsWithTs"] = "ts-jest/presets/js-with-ts";
7
- JestPresetNames["jsWIthBabel"] = "ts-jest/presets/js-with-babel";
8
- })(JestPresetNames = exports.JestPresetNames || (exports.JestPresetNames = {}));
9
3
  var definePreset = function (fullName) { return ({
10
4
  fullName: fullName,
11
5
  get name() {
@@ -30,10 +24,10 @@ var definePreset = function (fullName) { return ({
30
24
  return "const { " + this.jsVarName + ": " + varName + " } = require('ts-jest/presets')";
31
25
  },
32
26
  get isDefault() {
33
- return fullName === JestPresetNames.default;
27
+ return fullName === "ts-jest/presets/default";
34
28
  },
35
29
  }); };
36
30
  exports.allPresets = {};
37
- exports.defaults = (exports.allPresets[JestPresetNames.default] = definePreset(JestPresetNames.default));
38
- exports.jsWithTs = (exports.allPresets[JestPresetNames.jsWithTs] = definePreset(JestPresetNames.jsWithTs));
39
- exports.jsWIthBabel = (exports.allPresets[JestPresetNames.jsWIthBabel] = definePreset(JestPresetNames.jsWIthBabel));
31
+ exports.defaults = (exports.allPresets["ts-jest/presets/default"] = definePreset("ts-jest/presets/default"));
32
+ exports.jsWithTs = (exports.allPresets["ts-jest/presets/js-with-ts"] = definePreset("ts-jest/presets/js-with-ts"));
33
+ exports.jsWIthBabel = (exports.allPresets["ts-jest/presets/js-with-babel"] = definePreset("ts-jest/presets/js-with-babel"));
File without changes
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __values = (this && this.__values) || function(o) {
19
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
20
+ if (m) return m.call(o);
21
+ if (o && typeof o.length === "number") return {
22
+ next: function () {
23
+ if (o && i >= o.length) o = void 0;
24
+ return { value: o && o[i++], done: !o };
25
+ }
26
+ };
27
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ var fs_1 = require("fs");
31
+ var mkdirp = require("mkdirp");
32
+ var path_1 = require("path");
33
+ var sha1_1 = require("../util/sha1");
34
+ var language_service_1 = require("./language-service");
35
+ var program_1 = require("./program");
36
+ var transpile_module_1 = require("./transpile-module");
37
+ function updateOutput(outputText, normalizedFileName, sourceMap, getExtension) {
38
+ var base = path_1.basename(normalizedFileName);
39
+ var base64Map = Buffer.from(updateSourceMap(sourceMap, normalizedFileName), 'utf8').toString('base64');
40
+ var sourceMapContent = "data:application/json;charset=utf-8;base64," + base64Map;
41
+ var sourceMapLength = (base + ".map").length + (getExtension(normalizedFileName).length - path_1.extname(normalizedFileName).length);
42
+ return outputText.slice(0, -sourceMapLength) + sourceMapContent;
43
+ }
44
+ var updateSourceMap = function (sourceMapText, normalizedFileName) {
45
+ var sourceMap = JSON.parse(sourceMapText);
46
+ sourceMap.file = normalizedFileName;
47
+ sourceMap.sources = [normalizedFileName];
48
+ delete sourceMap.sourceRoot;
49
+ return JSON.stringify(sourceMap);
50
+ };
51
+ var getCacheName = function (sourceCode, normalizedFileName) {
52
+ return sha1_1.sha1(normalizedFileName, '\x00', sourceCode);
53
+ };
54
+ var isValidCacheContent = function (contents) {
55
+ return /(?:9|0=|Q==)$/.test(contents.slice(-3));
56
+ };
57
+ var readThrough = function (cachedir, memoryCache, compileFn, getExtension, logger) {
58
+ if (!cachedir) {
59
+ return function (code, fileName, lineOffset) {
60
+ var normalizedFileName = path_1.normalize(fileName);
61
+ logger.debug({ normalizedFileName: normalizedFileName }, 'readThrough(): no cache');
62
+ var _a = __read(compileFn(code, normalizedFileName, lineOffset), 2), value = _a[0], sourceMap = _a[1];
63
+ var output = updateOutput(value, fileName, sourceMap, getExtension);
64
+ memoryCache.outputs[normalizedFileName] = output;
65
+ return output;
66
+ };
67
+ }
68
+ mkdirp.sync(cachedir);
69
+ return function (code, fileName, lineOffset) {
70
+ var normalizedFileName = path_1.normalize(fileName), cachePath = path_1.join(cachedir, getCacheName(code, normalizedFileName)), extension = getExtension(normalizedFileName), outputPath = "" + cachePath + extension;
71
+ try {
72
+ var output_1 = fs_1.readFileSync(outputPath, 'utf8');
73
+ if (isValidCacheContent(output_1)) {
74
+ logger.debug({ normalizedFileName: normalizedFileName }, 'readThrough(): cache hit');
75
+ memoryCache.outputs[normalizedFileName] = output_1;
76
+ return output_1;
77
+ }
78
+ }
79
+ catch (err) { }
80
+ logger.debug({ fileName: fileName }, 'readThrough(): cache miss');
81
+ var _a = __read(compileFn(code, normalizedFileName, lineOffset), 2), value = _a[0], sourceMap = _a[1], output = updateOutput(value, normalizedFileName, sourceMap, getExtension);
82
+ logger.debug({ normalizedFileName: normalizedFileName, outputPath: outputPath }, 'readThrough(): writing caches');
83
+ memoryCache.outputs[normalizedFileName] = output;
84
+ fs_1.writeFileSync(outputPath, output);
85
+ return output;
86
+ };
87
+ };
88
+ exports.createCompiler = function (configs) {
89
+ var e_1, _a;
90
+ var logger = configs.logger.child({ namespace: 'ts-compiler' });
91
+ var _b = configs.typescript, compilerOptions = _b.options, fileNames = _b.fileNames, tsJest = configs.tsJest;
92
+ var cachedir = configs.tsCacheDir, ts = configs.compilerModule, extensions = ['.ts', '.tsx'], memoryCache = {
93
+ contents: Object.create(null),
94
+ versions: Object.create(null),
95
+ outputs: Object.create(null),
96
+ };
97
+ if (compilerOptions.allowJs) {
98
+ extensions.push('.js');
99
+ extensions.push('.jsx');
100
+ }
101
+ try {
102
+ for (var fileNames_1 = __values(fileNames), fileNames_1_1 = fileNames_1.next(); !fileNames_1_1.done; fileNames_1_1 = fileNames_1.next()) {
103
+ var path = fileNames_1_1.value;
104
+ memoryCache.versions[path_1.normalize(path)] = 1;
105
+ }
106
+ }
107
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
108
+ finally {
109
+ try {
110
+ if (fileNames_1_1 && !fileNames_1_1.done && (_a = fileNames_1.return)) _a.call(fileNames_1);
111
+ }
112
+ finally { if (e_1) throw e_1.error; }
113
+ }
114
+ var getExtension = compilerOptions.jsx === ts.JsxEmit.Preserve
115
+ ? function (path) { return (/\.[tj]sx$/.test(path) ? '.jsx' : '.js'); }
116
+ : function (_) { return '.js'; };
117
+ var compilerInstance;
118
+ if (!tsJest.isolatedModules) {
119
+ compilerInstance = !tsJest.compilerHost
120
+ ? language_service_1.compileUsingLanguageService(configs, logger, memoryCache)
121
+ : program_1.compileUsingProgram(configs, logger, memoryCache);
122
+ }
123
+ else {
124
+ compilerInstance = transpile_module_1.compileUsingTranspileModule(configs, logger);
125
+ }
126
+ var compile = readThrough(cachedir, memoryCache, compilerInstance.compileFn, getExtension, logger);
127
+ return { cwd: configs.cwd, compile: compile, program: compilerInstance.program, diagnose: compilerInstance.diagnoseFn };
128
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var bs_logger_1 = require("bs-logger");
4
+ var memoize = require("lodash.memoize");
5
+ var path_1 = require("path");
6
+ var messages_1 = require("../util/messages");
7
+ var hasOwn = Object.prototype.hasOwnProperty;
8
+ exports.compileUsingLanguageService = function (configs, logger, memoryCache) {
9
+ var _a;
10
+ logger.debug('compileUsingLanguageService(): create typescript compiler');
11
+ var ts = configs.compilerModule, cwd = configs.cwd, options = configs.typescript.options, serviceHostTraceCtx = (_a = {
12
+ namespace: 'ts:serviceHost',
13
+ call: null
14
+ },
15
+ _a[bs_logger_1.LogContexts.logLevel] = bs_logger_1.LogLevels.trace,
16
+ _a);
17
+ var projectVersion = 1;
18
+ var updateMemoryCache = function (code, fileName) {
19
+ var _a;
20
+ logger.debug({ fileName: fileName }, "updateMemoryCache(): update memory cache for language service");
21
+ var fileVersion = (_a = memoryCache.versions[fileName]) !== null && _a !== void 0 ? _a : 0, isFileInCache = fileVersion !== 0;
22
+ if (!isFileInCache) {
23
+ memoryCache.versions[fileName] = 1;
24
+ }
25
+ if (memoryCache.contents[fileName] !== code) {
26
+ memoryCache.contents[fileName] = code;
27
+ memoryCache.versions[fileName] = fileVersion + 1;
28
+ projectVersion++;
29
+ }
30
+ };
31
+ var serviceHost = {
32
+ getProjectVersion: function () { return String(projectVersion); },
33
+ getScriptFileNames: function () { return Object.keys(memoryCache.versions); },
34
+ getScriptVersion: function (fileName) {
35
+ var normalizedFileName = path_1.normalize(fileName), version = memoryCache.versions[normalizedFileName];
36
+ return version === undefined ? undefined : String(version);
37
+ },
38
+ getScriptSnapshot: function (fileName) {
39
+ var normalizedFileName = path_1.normalize(fileName), hit = hasOwn.call(memoryCache.contents, normalizedFileName);
40
+ logger.trace({ normalizedFileName: normalizedFileName, cacheHit: hit }, "getScriptSnapshot():", 'cache', hit ? 'hit' : 'miss');
41
+ if (!hit) {
42
+ memoryCache.contents[normalizedFileName] = ts.sys.readFile(normalizedFileName);
43
+ }
44
+ var contents = memoryCache.contents[normalizedFileName];
45
+ if (contents === undefined) {
46
+ return;
47
+ }
48
+ return ts.ScriptSnapshot.fromString(contents);
49
+ },
50
+ fileExists: memoize(ts.sys.fileExists),
51
+ readFile: logger.wrap(serviceHostTraceCtx, 'readFile', memoize(ts.sys.readFile)),
52
+ readDirectory: memoize(ts.sys.readDirectory),
53
+ getDirectories: memoize(ts.sys.getDirectories),
54
+ directoryExists: memoize(ts.sys.directoryExists),
55
+ realpath: memoize(ts.sys.realpath),
56
+ getNewLine: function () { return '\n'; },
57
+ getCurrentDirectory: function () { return cwd; },
58
+ getCompilationSettings: function () { return options; },
59
+ getDefaultLibFileName: function () { return ts.getDefaultLibFilePath(options); },
60
+ getCustomTransformers: function () { return configs.tsCustomTransformers; },
61
+ };
62
+ logger.debug('compileUsingLanguageService(): creating language service');
63
+ var service = ts.createLanguageService(serviceHost);
64
+ return {
65
+ compileFn: function (code, fileName) {
66
+ var normalizedFileName = path_1.normalize(fileName);
67
+ logger.debug({ normalizedFileName: normalizedFileName }, 'compileFn(): compiling using language service');
68
+ updateMemoryCache(code, normalizedFileName);
69
+ var output = service.getEmitOutput(normalizedFileName);
70
+ if (output.emitSkipped) {
71
+ throw new TypeError(path_1.relative(cwd, normalizedFileName) + ": Emit skipped for language service");
72
+ }
73
+ if (!output.outputFiles.length) {
74
+ throw new TypeError(messages_1.interpolate("Unable to require `.d.ts` file for file: {{file}}.\nThis is usually the result of a faulty configuration or import. Make sure there is a `.js`, `.json` or another executable extension available alongside `{{file}}`.", {
75
+ file: path_1.basename(normalizedFileName),
76
+ }));
77
+ }
78
+ return [output.outputFiles[1].text, output.outputFiles[0].text];
79
+ },
80
+ diagnoseFn: function (code, filePath) {
81
+ var normalizedFileName = path_1.normalize(filePath);
82
+ updateMemoryCache(code, normalizedFileName);
83
+ if (configs.shouldReportDiagnostic(normalizedFileName)) {
84
+ logger.debug({ normalizedFileName: normalizedFileName }, 'compileFn(): computing diagnostics for language service');
85
+ var diagnostics = service
86
+ .getCompilerOptionsDiagnostics()
87
+ .concat(service.getSyntacticDiagnostics(normalizedFileName))
88
+ .concat(service.getSemanticDiagnostics(normalizedFileName));
89
+ configs.raiseDiagnostics(diagnostics, normalizedFileName, logger);
90
+ }
91
+ },
92
+ program: service.getProgram(),
93
+ };
94
+ };
@@ -0,0 +1 @@
1
+ export {};