From 623b2f44cdf709c0fec90e03dd569db5a6eeb432 Mon Sep 17 00:00:00 2001 From: Huafu Gandon Date: Sun, 2 Sep 2018 20:21:24 +0200 Subject: [PATCH] feat(config): typeCheck default to true (langauge service) Renames `typeCheck` to `isolatedModules`. Default value (`false`) did not change, but that actually means the opposite BREAKING CHANGE: Language service will be used by default from now on --- README.md | 4 +- e2e/__helpers__/test-case/run-result.ts | 2 +- e2e/__templates__/default/package-lock.json | 14 +- e2e/__templates__/default/package.json | 2 + e2e/__templates__/default/tsconfig.json | 7 + .../with-babel-6/package-lock.json | 14 +- e2e/__templates__/with-babel-6/package.json | 2 + e2e/__templates__/with-babel-6/tsconfig.json | 7 + .../with-babel-7/package-lock.json | 14 +- e2e/__templates__/with-babel-7/package.json | 2 + e2e/__templates__/with-babel-7/tsconfig.json | 7 + .../with-jest-22/package-lock.json | 14 +- e2e/__templates__/with-jest-22/package.json | 2 + e2e/__templates__/with-jest-22/tsconfig.json | 7 + .../with-typescript-2-7/package-lock.json | 14 +- .../with-typescript-2-7/package.json | 2 + .../with-typescript-2-7/tsconfig.json | 7 + .../package-lock.json | 14 +- .../with-unsupported-version/package.json | 2 + .../with-unsupported-version/tsconfig.json | 7 + .../__snapshots__/logger.test.ts.snap | 226 +++++- .../__snapshots__/source-map.test.ts.snap | 10 +- .../__snapshots__/type-checking.test.ts.snap | 20 +- e2e/__tests__/const-enum.test.ts | 4 +- e2e/__tests__/source-map.test.ts | 3 + e2e/__tests__/type-checking.test.ts | 6 +- package.json | 3 +- src/__helpers__/fakers.ts | 2 +- src/compiler.spec.ts | 730 +++++++++++++++++- src/compiler.ts | 7 +- .../__snapshots__/config-set.spec.ts.snap | 2 +- src/config/config-set.spec.ts | 12 +- src/index.spec.ts | 6 +- src/types.ts | 8 +- src/util/__snapshots__/backports.spec.ts.snap | 50 ++ src/util/backports.spec.ts | 5 + src/util/backports.ts | 6 + src/util/messages.ts | 2 +- 38 files changed, 1159 insertions(+), 87 deletions(-) create mode 100644 e2e/__templates__/default/tsconfig.json create mode 100644 e2e/__templates__/with-babel-6/tsconfig.json create mode 100644 e2e/__templates__/with-babel-7/tsconfig.json create mode 100644 e2e/__templates__/with-jest-22/tsconfig.json create mode 100644 e2e/__templates__/with-typescript-2-7/tsconfig.json create mode 100644 e2e/__templates__/with-unsupported-version/tsconfig.json diff --git a/README.md b/README.md index 621fca1d23..9fa75e2f84 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ - [Logging](#logging) - [Known Limitations](#known-limitations) - [Known limitations for TS compiler options](#known-limitations-for-ts-compiler-options) - - [`const enum` is not supported if `typeCheck` is not enabled](#const-enum-is-not-supported-if-typecheck-is-not-enabled) + - [`const enum` is not supported if `isolatedModules` is enabled](#const-enum-is-not-supported-if-isolatedmodules-is-enabled) - [How to Contribute](#how-to-contribute) - [Quickstart to run tests (only if you're working on this package)](#quickstart-to-run-tests-only-if-youre-working-on-this-package) - [License](#license) @@ -405,7 +405,7 @@ If you use `"baseUrl": ""`, you also have to change `jest } ``` -### `const enum` is not supported if `typeCheck` is not enabled +### `const enum` is not supported if `isolatedModules` is enabled This is due to a limitation in the ts-jest basic processor which compiles each test file individually, therefore ignoring implementations of ambient declarations. The TypeScript team currently have [no plan to support const enum inlining](https://github.com/Microsoft/TypeScript/issues/5243) for this particular compiler method. See [#112](https://github.com/kulshekhar/ts-jest/issues/112) and [#281](https://github.com/kulshekhar/ts-jest/issues/281) for more information. diff --git a/e2e/__helpers__/test-case/run-result.ts b/e2e/__helpers__/test-case/run-result.ts index 97a6a057f4..819b5f8377 100644 --- a/e2e/__helpers__/test-case/run-result.ts +++ b/e2e/__helpers__/test-case/run-result.ts @@ -48,7 +48,7 @@ export default class RunResult { try { io = require(`${this.context.ioDir}/${relFilePath}.json`) } catch (err) { - io.out = `/* ts-jest after hook has not been called! ${err} */` + io.out = `/*\nts-jest after hook has not been called!\n${err}\noutput:\n${this.output}*/` } return new ProcessedFileIo(this.cwd, relFilePath, io.in, io.out) } diff --git a/e2e/__templates__/default/package-lock.json b/e2e/__templates__/default/package-lock.json index c0f48904a5..99c22e5506 100644 --- a/e2e/__templates__/default/package-lock.json +++ b/e2e/__templates__/default/package-lock.json @@ -119,6 +119,12 @@ "integrity": "sha512-/UMY+2GkOZ27Vrc51pqC5J8SPd39FKt7kkoGAtWJ8s4msj0b15KehDWIiJpWY3/7tLxBQLLzJhIBhnEsXdzpgw==", "dev": true }, + "@types/node": { + "version": "10.9.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.9.4.tgz", + "integrity": "sha512-fCHV45gS+m3hH17zgkgADUSi2RR1Vht6wOZ0jyHP8rjiQra9f+mIcgwPQHllmDocYOstIEbKlxbFDYlgrTPYqw==", + "dev": true + }, "abab": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.0.tgz", @@ -3802,9 +3808,9 @@ "dev": true }, "nwsapi": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.8.tgz", - "integrity": "sha512-7RZ+qbFGiVc6v14Y8DSZjPN1wZPOaMbiiP4tzf5eNuyOITAeOIA3cMhjuKUypVIqBgCSg1KaSyAv8Ocq/0ZJ1A==", + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.9.tgz", + "integrity": "sha512-nlWFSCTYQcHk/6A9FFnfhKc14c3aFhfdNBXgo8Qgi9QTBu/qg3Ww+Uiz9wMzXd1T8GFxPc2QIHB6Qtf2XFryFQ==", "dev": true }, "oauth-sign": { @@ -5539,7 +5545,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "dev": true, "requires": { diff --git a/e2e/__templates__/default/package.json b/e2e/__templates__/default/package.json index f9fc3c7719..201a234cfd 100644 --- a/e2e/__templates__/default/package.json +++ b/e2e/__templates__/default/package.json @@ -4,11 +4,13 @@ "private": true, "devDependencies": { "@types/jest": "23.3.1", + "@types/node": "10.9.4", "jest": "23.5.0", "typescript": "3.0.3" }, "wantedDependencies": { "@types/jest": "latest", + "@types/node": "latest", "jest": "latest", "typescript": "latest" } diff --git a/e2e/__templates__/default/tsconfig.json b/e2e/__templates__/default/tsconfig.json new file mode 100644 index 0000000000..fdc01d5571 --- /dev/null +++ b/e2e/__templates__/default/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": [ + "jest", "node" + ] + } +} diff --git a/e2e/__templates__/with-babel-6/package-lock.json b/e2e/__templates__/with-babel-6/package-lock.json index c89088558e..658e13b344 100644 --- a/e2e/__templates__/with-babel-6/package-lock.json +++ b/e2e/__templates__/with-babel-6/package-lock.json @@ -183,6 +183,12 @@ "integrity": "sha512-/UMY+2GkOZ27Vrc51pqC5J8SPd39FKt7kkoGAtWJ8s4msj0b15KehDWIiJpWY3/7tLxBQLLzJhIBhnEsXdzpgw==", "dev": true }, + "@types/node": { + "version": "10.9.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.9.4.tgz", + "integrity": "sha512-fCHV45gS+m3hH17zgkgADUSi2RR1Vht6wOZ0jyHP8rjiQra9f+mIcgwPQHllmDocYOstIEbKlxbFDYlgrTPYqw==", + "dev": true + }, "abab": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.0.tgz", @@ -4212,9 +4218,9 @@ "dev": true }, "nwsapi": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.8.tgz", - "integrity": "sha512-7RZ+qbFGiVc6v14Y8DSZjPN1wZPOaMbiiP4tzf5eNuyOITAeOIA3cMhjuKUypVIqBgCSg1KaSyAv8Ocq/0ZJ1A==", + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.9.tgz", + "integrity": "sha512-nlWFSCTYQcHk/6A9FFnfhKc14c3aFhfdNBXgo8Qgi9QTBu/qg3Ww+Uiz9wMzXd1T8GFxPc2QIHB6Qtf2XFryFQ==", "dev": true }, "oauth-sign": { @@ -5963,7 +5969,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "dev": true, "requires": { diff --git a/e2e/__templates__/with-babel-6/package.json b/e2e/__templates__/with-babel-6/package.json index 6a94aa5dbe..1a642b82e6 100644 --- a/e2e/__templates__/with-babel-6/package.json +++ b/e2e/__templates__/with-babel-6/package.json @@ -4,12 +4,14 @@ "private": true, "devDependencies": { "@types/jest": "23.3.1", + "@types/node": "10.9.4", "babel-core": "6.26.3", "jest": "23.5.0", "typescript": "3.0.3" }, "wantedDependencies": { "@types/jest": "latest", + "@types/node": "latest", "babel-core": "6", "jest": "latest", "typescript": "latest" diff --git a/e2e/__templates__/with-babel-6/tsconfig.json b/e2e/__templates__/with-babel-6/tsconfig.json new file mode 100644 index 0000000000..fdc01d5571 --- /dev/null +++ b/e2e/__templates__/with-babel-6/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": [ + "jest", "node" + ] + } +} diff --git a/e2e/__templates__/with-babel-7/package-lock.json b/e2e/__templates__/with-babel-7/package-lock.json index 701e4fbde2..4a55bf145f 100644 --- a/e2e/__templates__/with-babel-7/package-lock.json +++ b/e2e/__templates__/with-babel-7/package-lock.json @@ -150,6 +150,12 @@ "integrity": "sha512-/UMY+2GkOZ27Vrc51pqC5J8SPd39FKt7kkoGAtWJ8s4msj0b15KehDWIiJpWY3/7tLxBQLLzJhIBhnEsXdzpgw==", "dev": true }, + "@types/node": { + "version": "10.9.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.9.4.tgz", + "integrity": "sha512-fCHV45gS+m3hH17zgkgADUSi2RR1Vht6wOZ0jyHP8rjiQra9f+mIcgwPQHllmDocYOstIEbKlxbFDYlgrTPYqw==", + "dev": true + }, "abab": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.0.tgz", @@ -4044,9 +4050,9 @@ "dev": true }, "nwsapi": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.8.tgz", - "integrity": "sha512-7RZ+qbFGiVc6v14Y8DSZjPN1wZPOaMbiiP4tzf5eNuyOITAeOIA3cMhjuKUypVIqBgCSg1KaSyAv8Ocq/0ZJ1A==", + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.9.tgz", + "integrity": "sha512-nlWFSCTYQcHk/6A9FFnfhKc14c3aFhfdNBXgo8Qgi9QTBu/qg3Ww+Uiz9wMzXd1T8GFxPc2QIHB6Qtf2XFryFQ==", "dev": true }, "oauth-sign": { @@ -5784,7 +5790,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "dev": true, "requires": { diff --git a/e2e/__templates__/with-babel-7/package.json b/e2e/__templates__/with-babel-7/package.json index 8819cd8ae5..12c619ec0b 100644 --- a/e2e/__templates__/with-babel-7/package.json +++ b/e2e/__templates__/with-babel-7/package.json @@ -5,6 +5,7 @@ "devDependencies": { "@babel/core": "7.0.0", "@types/jest": "23.3.1", + "@types/node": "10.9.4", "babel-core": "7.0.0-bridge.0", "jest": "23.5.0", "typescript": "3.0.3" @@ -12,6 +13,7 @@ "wantedDependencies": { "@babel/core": "7", "@types/jest": "latest", + "@types/node": "latest", "babel-core": "7.0.0-bridge.0", "jest": "latest", "typescript": "latest" diff --git a/e2e/__templates__/with-babel-7/tsconfig.json b/e2e/__templates__/with-babel-7/tsconfig.json new file mode 100644 index 0000000000..fdc01d5571 --- /dev/null +++ b/e2e/__templates__/with-babel-7/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": [ + "jest", "node" + ] + } +} diff --git a/e2e/__templates__/with-jest-22/package-lock.json b/e2e/__templates__/with-jest-22/package-lock.json index ce5a9af816..be33c12000 100644 --- a/e2e/__templates__/with-jest-22/package-lock.json +++ b/e2e/__templates__/with-jest-22/package-lock.json @@ -119,6 +119,12 @@ "integrity": "sha512-e74sM9W/4qqWB6D4TWV9FQk0WoHtX1X4FJpbjxucMSVJHtFjbQOH3H6yp+xno4br0AKG0wz/kPtaN599GUOvAg==", "dev": true }, + "@types/node": { + "version": "10.9.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.9.4.tgz", + "integrity": "sha512-fCHV45gS+m3hH17zgkgADUSi2RR1Vht6wOZ0jyHP8rjiQra9f+mIcgwPQHllmDocYOstIEbKlxbFDYlgrTPYqw==", + "dev": true + }, "abab": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.0.tgz", @@ -3767,9 +3773,9 @@ "dev": true }, "nwsapi": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.8.tgz", - "integrity": "sha512-7RZ+qbFGiVc6v14Y8DSZjPN1wZPOaMbiiP4tzf5eNuyOITAeOIA3cMhjuKUypVIqBgCSg1KaSyAv8Ocq/0ZJ1A==", + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.9.tgz", + "integrity": "sha512-nlWFSCTYQcHk/6A9FFnfhKc14c3aFhfdNBXgo8Qgi9QTBu/qg3Ww+Uiz9wMzXd1T8GFxPc2QIHB6Qtf2XFryFQ==", "dev": true }, "oauth-sign": { @@ -5497,7 +5503,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "dev": true, "requires": { diff --git a/e2e/__templates__/with-jest-22/package.json b/e2e/__templates__/with-jest-22/package.json index 6d12a10577..e7c5a33fdb 100644 --- a/e2e/__templates__/with-jest-22/package.json +++ b/e2e/__templates__/with-jest-22/package.json @@ -4,11 +4,13 @@ "private": true, "devDependencies": { "@types/jest": "22.2.3", + "@types/node": "10.9.4", "jest": "22.4.4", "typescript": "3.0.3" }, "wantedDependencies": { "@types/jest": "22", + "@types/node": "latest", "jest": "22", "typescript": "latest" } diff --git a/e2e/__templates__/with-jest-22/tsconfig.json b/e2e/__templates__/with-jest-22/tsconfig.json new file mode 100644 index 0000000000..fdc01d5571 --- /dev/null +++ b/e2e/__templates__/with-jest-22/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": [ + "jest", "node" + ] + } +} diff --git a/e2e/__templates__/with-typescript-2-7/package-lock.json b/e2e/__templates__/with-typescript-2-7/package-lock.json index 3dc6502460..4ab54ce005 100644 --- a/e2e/__templates__/with-typescript-2-7/package-lock.json +++ b/e2e/__templates__/with-typescript-2-7/package-lock.json @@ -119,6 +119,12 @@ "integrity": "sha512-/UMY+2GkOZ27Vrc51pqC5J8SPd39FKt7kkoGAtWJ8s4msj0b15KehDWIiJpWY3/7tLxBQLLzJhIBhnEsXdzpgw==", "dev": true }, + "@types/node": { + "version": "10.9.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.9.4.tgz", + "integrity": "sha512-fCHV45gS+m3hH17zgkgADUSi2RR1Vht6wOZ0jyHP8rjiQra9f+mIcgwPQHllmDocYOstIEbKlxbFDYlgrTPYqw==", + "dev": true + }, "abab": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.0.tgz", @@ -3802,9 +3808,9 @@ "dev": true }, "nwsapi": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.8.tgz", - "integrity": "sha512-7RZ+qbFGiVc6v14Y8DSZjPN1wZPOaMbiiP4tzf5eNuyOITAeOIA3cMhjuKUypVIqBgCSg1KaSyAv8Ocq/0ZJ1A==", + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.9.tgz", + "integrity": "sha512-nlWFSCTYQcHk/6A9FFnfhKc14c3aFhfdNBXgo8Qgi9QTBu/qg3Ww+Uiz9wMzXd1T8GFxPc2QIHB6Qtf2XFryFQ==", "dev": true }, "oauth-sign": { @@ -5539,7 +5545,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "dev": true, "requires": { diff --git a/e2e/__templates__/with-typescript-2-7/package.json b/e2e/__templates__/with-typescript-2-7/package.json index 37cbc279eb..0e2f2f5182 100644 --- a/e2e/__templates__/with-typescript-2-7/package.json +++ b/e2e/__templates__/with-typescript-2-7/package.json @@ -4,11 +4,13 @@ "private": true, "devDependencies": { "@types/jest": "23.3.1", + "@types/node": "10.9.4", "jest": "23.5.0", "typescript": "2.7.2" }, "wantedDependencies": { "@types/jest": "latest", + "@types/node": "latest", "jest": "latest", "typescript": "2.7" } diff --git a/e2e/__templates__/with-typescript-2-7/tsconfig.json b/e2e/__templates__/with-typescript-2-7/tsconfig.json new file mode 100644 index 0000000000..fdc01d5571 --- /dev/null +++ b/e2e/__templates__/with-typescript-2-7/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": [ + "jest", "node" + ] + } +} diff --git a/e2e/__templates__/with-unsupported-version/package-lock.json b/e2e/__templates__/with-unsupported-version/package-lock.json index 8ac64453b4..641da0731e 100644 --- a/e2e/__templates__/with-unsupported-version/package-lock.json +++ b/e2e/__templates__/with-unsupported-version/package-lock.json @@ -119,6 +119,12 @@ "integrity": "sha512-/UMY+2GkOZ27Vrc51pqC5J8SPd39FKt7kkoGAtWJ8s4msj0b15KehDWIiJpWY3/7tLxBQLLzJhIBhnEsXdzpgw==", "dev": true }, + "@types/node": { + "version": "10.9.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.9.4.tgz", + "integrity": "sha512-fCHV45gS+m3hH17zgkgADUSi2RR1Vht6wOZ0jyHP8rjiQra9f+mIcgwPQHllmDocYOstIEbKlxbFDYlgrTPYqw==", + "dev": true + }, "abab": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.0.tgz", @@ -3802,9 +3808,9 @@ "dev": true }, "nwsapi": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.8.tgz", - "integrity": "sha512-7RZ+qbFGiVc6v14Y8DSZjPN1wZPOaMbiiP4tzf5eNuyOITAeOIA3cMhjuKUypVIqBgCSg1KaSyAv8Ocq/0ZJ1A==", + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.9.tgz", + "integrity": "sha512-nlWFSCTYQcHk/6A9FFnfhKc14c3aFhfdNBXgo8Qgi9QTBu/qg3Ww+Uiz9wMzXd1T8GFxPc2QIHB6Qtf2XFryFQ==", "dev": true }, "oauth-sign": { @@ -5539,7 +5545,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "dev": true, "requires": { diff --git a/e2e/__templates__/with-unsupported-version/package.json b/e2e/__templates__/with-unsupported-version/package.json index fb5fa82f2c..ed48038a52 100644 --- a/e2e/__templates__/with-unsupported-version/package.json +++ b/e2e/__templates__/with-unsupported-version/package.json @@ -4,11 +4,13 @@ "private": true, "devDependencies": { "@types/jest": "23.3.1", + "@types/node": "10.9.4", "jest": "23.5.0", "typescript": "2.5.3" }, "wantedDependencies": { "@types/jest": "latest", + "@types/node": "latest", "jest": "latest", "typescript": "2.5" } diff --git a/e2e/__templates__/with-unsupported-version/tsconfig.json b/e2e/__templates__/with-unsupported-version/tsconfig.json new file mode 100644 index 0000000000..fdc01d5571 --- /dev/null +++ b/e2e/__templates__/with-unsupported-version/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": [ + "jest", "node" + ] + } +} diff --git a/e2e/__tests__/__snapshots__/logger.test.ts.snap b/e2e/__tests__/__snapshots__/logger.test.ts.snap index 585034315d..99fe916a55 100644 --- a/e2e/__tests__/__snapshots__/logger.test.ts.snap +++ b/e2e/__tests__/__snapshots__/logger.test.ts.snap @@ -16,19 +16,59 @@ Array [ "[level:20] loaded module typescript", "[level:20] patching typescript", "[level:20] checking version of typescript: OK", + "[level:20] readTsConfig(): reading /tsconfig.json", "[level:20] normalized typescript config", "[level:20] processing /Hello.spec.ts", - "[level:20] creating typescript compiler without type-checking", + "[level:20] creating typescript compiler (language service)", "[level:20] will use file caching", + "[level:20] creating language service", "[level:20] readThrough(): cache miss", - "[level:20] getOutput(): compiling as isolated module", + "[level:20] getOutput(): compiling using language service", + "[level:20] updateMemoryCache()", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] readFile", + "[level:20] readFile", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", "[level:20] visitSourceFileNode(): hoisting", + "[level:20] getOutput(): computing diagnostics", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", "[level:20] readThrough(): writing caches", "[level:20] computing cache key for /Hello.ts", "[level:20] processing /Hello.ts", "[level:20] readThrough(): cache miss", - "[level:20] getOutput(): compiling as isolated module", + "[level:20] getOutput(): compiling using language service", + "[level:20] updateMemoryCache()", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", "[level:20] visitSourceFileNode(): hoisting", + "[level:20] getOutput(): computing diagnostics", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", "[level:20] readThrough(): writing caches", ] `; @@ -53,6 +93,7 @@ Array [ "[level:20] loaded module typescript", "[level:20] patching typescript", "[level:20] checking version of typescript: OK", + "[level:20] readTsConfig(): reading /tsconfig.json", "[level:20] normalized typescript config", "[level:20] processing /Hello.spec.ts", "[level:20] creating babel-jest transformer", @@ -60,18 +101,57 @@ Array [ "[level:20] loaded module babel-jest", "[level:20] patching babel-jest", "[level:20] checking version of babel-jest: OK", - "[level:20] creating typescript compiler without type-checking", + "[level:20] creating typescript compiler (language service)", "[level:20] will use file caching", + "[level:20] creating language service", "[level:20] readThrough(): cache miss", - "[level:20] getOutput(): compiling as isolated module", + "[level:20] getOutput(): compiling using language service", + "[level:20] updateMemoryCache()", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] readFile", + "[level:20] readFile", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", "[level:20] visitSourceFileNode(): hoisting", + "[level:20] getOutput(): computing diagnostics", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", "[level:20] readThrough(): writing caches", "[level:20] calling babel-jest processor", "[level:20] computing cache key for /Hello.ts", "[level:20] processing /Hello.ts", "[level:20] readThrough(): cache miss", - "[level:20] getOutput(): compiling as isolated module", + "[level:20] getOutput(): compiling using language service", + "[level:20] updateMemoryCache()", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", "[level:20] visitSourceFileNode(): hoisting", + "[level:20] getOutput(): computing diagnostics", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", "[level:20] readThrough(): writing caches", "[level:20] calling babel-jest processor", ] @@ -96,6 +176,7 @@ Array [ "[level:20] loaded module typescript", "[level:20] patching typescript", "[level:20] checking version of typescript: OK", + "[level:20] readTsConfig(): reading /tsconfig.json", "[level:20] normalized typescript config", "[level:20] processing /Hello.spec.ts", "[level:20] creating babel-jest transformer", @@ -103,18 +184,57 @@ Array [ "[level:20] loaded module babel-jest", "[level:20] patching babel-jest", "[level:20] checking version of babel-jest: OK", - "[level:20] creating typescript compiler without type-checking", + "[level:20] creating typescript compiler (language service)", "[level:20] will use file caching", + "[level:20] creating language service", "[level:20] readThrough(): cache miss", - "[level:20] getOutput(): compiling as isolated module", + "[level:20] getOutput(): compiling using language service", + "[level:20] updateMemoryCache()", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] readFile", + "[level:20] readFile", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", "[level:20] visitSourceFileNode(): hoisting", + "[level:20] getOutput(): computing diagnostics", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", "[level:20] readThrough(): writing caches", "[level:20] calling babel-jest processor", "[level:20] computing cache key for /Hello.ts", "[level:20] processing /Hello.ts", "[level:20] readThrough(): cache miss", - "[level:20] getOutput(): compiling as isolated module", + "[level:20] getOutput(): compiling using language service", + "[level:20] updateMemoryCache()", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", "[level:20] visitSourceFileNode(): hoisting", + "[level:20] getOutput(): computing diagnostics", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", "[level:20] readThrough(): writing caches", "[level:20] calling babel-jest processor", ] @@ -135,19 +255,59 @@ Array [ "[level:20] loaded module typescript", "[level:20] patching typescript", "[level:20] checking version of typescript: OK", + "[level:20] readTsConfig(): reading /tsconfig.json", "[level:20] normalized typescript config", "[level:20] processing /Hello.spec.ts", - "[level:20] creating typescript compiler without type-checking", + "[level:20] creating typescript compiler (language service)", "[level:20] will use file caching", + "[level:20] creating language service", "[level:20] readThrough(): cache miss", - "[level:20] getOutput(): compiling as isolated module", + "[level:20] getOutput(): compiling using language service", + "[level:20] updateMemoryCache()", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] readFile", + "[level:20] readFile", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", "[level:20] visitSourceFileNode(): hoisting", + "[level:20] getOutput(): computing diagnostics", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", "[level:20] readThrough(): writing caches", "[level:20] computing cache key for /Hello.ts", "[level:20] processing /Hello.ts", "[level:20] readThrough(): cache miss", - "[level:20] getOutput(): compiling as isolated module", + "[level:20] getOutput(): compiling using language service", + "[level:20] updateMemoryCache()", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", "[level:20] visitSourceFileNode(): hoisting", + "[level:20] getOutput(): computing diagnostics", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", "[level:20] readThrough(): writing caches", ] `; @@ -168,19 +328,55 @@ Array [ "[level:20] loaded module typescript", "[level:20] patching typescript", "[level:20] checking version of typescript: OK", + "[level:20] readTsConfig(): reading /tsconfig.json", "[level:20] normalized typescript config", "[level:20] processing /Hello.spec.ts", - "[level:20] creating typescript compiler without type-checking", + "[level:20] creating typescript compiler (language service)", "[level:20] will use file caching", + "[level:20] creating language service", "[level:20] readThrough(): cache miss", - "[level:20] getOutput(): compiling as isolated module", + "[level:20] getOutput(): compiling using language service", + "[level:20] updateMemoryCache()", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] readFile", + "[level:20] readFile", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", + "[level:20] getScriptSnapshot(): cache miss", "[level:20] visitSourceFileNode(): hoisting", + "[level:20] getOutput(): computing diagnostics", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", "[level:20] readThrough(): writing caches", "[level:20] computing cache key for /Hello.ts", "[level:20] processing /Hello.ts", "[level:20] readThrough(): cache miss", - "[level:20] getOutput(): compiling as isolated module", + "[level:20] getOutput(): compiling using language service", + "[level:20] updateMemoryCache()", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", "[level:20] visitSourceFileNode(): hoisting", + "[level:20] getOutput(): computing diagnostics", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", + "[level:20] getScriptSnapshot(): cache hit", "[level:20] readThrough(): writing caches", ] `; diff --git a/e2e/__tests__/__snapshots__/source-map.test.ts.snap b/e2e/__tests__/__snapshots__/source-map.test.ts.snap index 2cec1e4105..5d232ccaa8 100644 --- a/e2e/__tests__/__snapshots__/source-map.test.ts.snap +++ b/e2e/__tests__/__snapshots__/source-map.test.ts.snap @@ -35,7 +35,7 @@ exports[`using template "default" should have the source mpas comment 1`] = ` `; exports[`using template "default" should report correct line numbers 1`] = ` - × jest + × jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"diagnostics":{"ignoreCodes":[5023,7027]}}}} ↳ exit code: 1 ===[ STDOUT ]=================================================================== console.log main.ts:2 @@ -123,7 +123,7 @@ exports[`using template "with-babel-6" should have the source mpas comment 1`] = `; exports[`using template "with-babel-6" should report correct line numbers 1`] = ` - × jest + × jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"babelConfig":true,"diagnostics":{"ignoreCodes":[5023,7027]}}}} ↳ exit code: 1 ===[ STDOUT ]=================================================================== console.log main.ts:2 @@ -217,7 +217,7 @@ exports[`using template "with-babel-7" should have the source mpas comment 1`] = `; exports[`using template "with-babel-7" should report correct line numbers 1`] = ` - × jest + × jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"babelConfig":true,"diagnostics":{"ignoreCodes":[5023,7027]}}}} ↳ exit code: 1 ===[ STDOUT ]=================================================================== console.log main.ts:2 @@ -305,7 +305,7 @@ exports[`using template "with-jest-22" should have the source mpas comment 1`] = `; exports[`using template "with-jest-22" should report correct line numbers 1`] = ` - × jest + × jest --config {"transform":{"^.+\\\\.tsx?$":"ts-jest"},"testMatch":["**/__tests__/**/*.js?(x)","**/?(*.)+(spec|test).js?(x)","**/__tests__/**/*.ts?(x)","**/?(*.)+(spec|test).ts?(x)"],"moduleFileExtensions":["js","json","jsx","node","ts","tsx"],"testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"diagnostics":{"ignoreCodes":[5023,7027]}}}} ↳ exit code: 1 ===[ STDOUT ]=================================================================== console.log main.ts:2 @@ -391,7 +391,7 @@ exports[`using template "with-typescript-2-7" should have the source mpas commen `; exports[`using template "with-typescript-2-7" should report correct line numbers 1`] = ` - × jest + × jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"diagnostics":{"ignoreCodes":[5023,7027]}}}} ↳ exit code: 1 ===[ STDOUT ]=================================================================== console.log main.ts:2 diff --git a/e2e/__tests__/__snapshots__/type-checking.test.ts.snap b/e2e/__tests__/__snapshots__/type-checking.test.ts.snap index 4434f7b8e3..11ce0f0dcf 100644 --- a/e2e/__tests__/__snapshots__/type-checking.test.ts.snap +++ b/e2e/__tests__/__snapshots__/type-checking.test.ts.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`With type checking should fail using template "default" 1`] = ` - × jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"typeCheck":true}}} + × jest ↳ exit code: 1 ===[ STDOUT ]=================================================================== @@ -24,7 +24,7 @@ exports[`With type checking should fail using template "default" 1`] = ` `; exports[`With type checking should fail using template "with-babel-6" 1`] = ` - × jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"babelConfig":true,"typeCheck":true}}} + × jest ↳ exit code: 1 ===[ STDOUT ]=================================================================== @@ -47,7 +47,7 @@ exports[`With type checking should fail using template "with-babel-6" 1`] = ` `; exports[`With type checking should fail using template "with-babel-7" 1`] = ` - × jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"babelConfig":true,"typeCheck":true}}} + × jest ↳ exit code: 1 ===[ STDOUT ]=================================================================== @@ -70,7 +70,7 @@ exports[`With type checking should fail using template "with-babel-7" 1`] = ` `; exports[`With type checking should fail using template "with-jest-22" 1`] = ` - × jest --config {"transform":{"^.+\\\\.tsx?$":"ts-jest"},"testMatch":["**/__tests__/**/*.js?(x)","**/?(*.)+(spec|test).js?(x)","**/__tests__/**/*.ts?(x)","**/?(*.)+(spec|test).ts?(x)"],"moduleFileExtensions":["js","json","jsx","node","ts","tsx"],"testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"typeCheck":true}}} + × jest ↳ exit code: 1 ===[ STDOUT ]=================================================================== @@ -93,7 +93,7 @@ exports[`With type checking should fail using template "with-jest-22" 1`] = ` `; exports[`With type checking should fail using template "with-typescript-2-7" 1`] = ` - × jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"diagnostics":{"ignoreCodes":[5023]},"typeCheck":true}}} + × jest ↳ exit code: 1 ===[ STDOUT ]=================================================================== @@ -116,7 +116,7 @@ exports[`With type checking should fail using template "with-typescript-2-7" 1`] `; exports[`Without type checking should pass using template "default" 1`] = ` - √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"typeCheck":false}}} + √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"isolatedModules":true}}} ↳ exit code: 0 ===[ STDOUT ]=================================================================== @@ -133,7 +133,7 @@ exports[`Without type checking should pass using template "default" 1`] = ` `; exports[`Without type checking should pass using template "with-babel-6" 1`] = ` - √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"babelConfig":true,"typeCheck":false}}} + √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"babelConfig":true,"isolatedModules":true}}} ↳ exit code: 0 ===[ STDOUT ]=================================================================== @@ -150,7 +150,7 @@ exports[`Without type checking should pass using template "with-babel-6" 1`] = ` `; exports[`Without type checking should pass using template "with-babel-7" 1`] = ` - √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"babelConfig":true,"typeCheck":false}}} + √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"babelConfig":true,"isolatedModules":true}}} ↳ exit code: 0 ===[ STDOUT ]=================================================================== @@ -167,7 +167,7 @@ exports[`Without type checking should pass using template "with-babel-7" 1`] = ` `; exports[`Without type checking should pass using template "with-jest-22" 1`] = ` - √ jest --config {"transform":{"^.+\\\\.tsx?$":"ts-jest"},"testMatch":["**/__tests__/**/*.js?(x)","**/?(*.)+(spec|test).js?(x)","**/__tests__/**/*.ts?(x)","**/?(*.)+(spec|test).ts?(x)"],"moduleFileExtensions":["js","json","jsx","node","ts","tsx"],"testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"typeCheck":false}}} + √ jest --config {"transform":{"^.+\\\\.tsx?$":"ts-jest"},"testMatch":["**/__tests__/**/*.js?(x)","**/?(*.)+(spec|test).js?(x)","**/__tests__/**/*.ts?(x)","**/?(*.)+(spec|test).ts?(x)"],"moduleFileExtensions":["js","json","jsx","node","ts","tsx"],"testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"isolatedModules":true}}} ↳ exit code: 0 ===[ STDOUT ]=================================================================== @@ -184,7 +184,7 @@ exports[`Without type checking should pass using template "with-jest-22" 1`] = ` `; exports[`Without type checking should pass using template "with-typescript-2-7" 1`] = ` - √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"diagnostics":{"ignoreCodes":[5023]},"typeCheck":false}}} + √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"diagnostics":{"ignoreCodes":[5023]},"isolatedModules":true}}} ↳ exit code: 0 ===[ STDOUT ]=================================================================== diff --git a/e2e/__tests__/const-enum.test.ts b/e2e/__tests__/const-enum.test.ts index 4df15b0926..1f3f622928 100644 --- a/e2e/__tests__/const-enum.test.ts +++ b/e2e/__tests__/const-enum.test.ts @@ -2,9 +2,7 @@ import { configureTestCase } from '../__helpers__/test-case' import { allValidPackageSets } from '../__helpers__/templates' describe('Const enum', () => { - const testCase = configureTestCase('const-enum', { - tsJestConfig: { typeCheck: true }, - }) + const testCase = configureTestCase('const-enum') testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => { it(testLabel, () => { diff --git a/e2e/__tests__/source-map.test.ts b/e2e/__tests__/source-map.test.ts index fe83d26636..6311f8d415 100644 --- a/e2e/__tests__/source-map.test.ts +++ b/e2e/__tests__/source-map.test.ts @@ -3,6 +3,9 @@ import { allValidPackageSets } from '../__helpers__/templates' const testCase = configureTestCase('source-maps', { writeIo: true, + // TS5023 - unrecognized compiler option + // TS7027 - unreachable code + tsJestConfig: { diagnostics: { ignoreCodes: [5023, 7027] } }, }) testCase.runWithTemplates(allValidPackageSets, 1, (runTest, { templateName }) => { diff --git a/e2e/__tests__/type-checking.test.ts b/e2e/__tests__/type-checking.test.ts index d1cadfa018..7380c96d4a 100644 --- a/e2e/__tests__/type-checking.test.ts +++ b/e2e/__tests__/type-checking.test.ts @@ -2,9 +2,7 @@ import { configureTestCase } from '../__helpers__/test-case' import { allValidPackageSets } from '../__helpers__/templates' describe('With type checking', () => { - const testCase = configureTestCase('type-checking', { - tsJestConfig: { typeCheck: true }, - }) + const testCase = configureTestCase('type-checking') testCase.runWithTemplates(allValidPackageSets, 1, (runTest, { testLabel }) => { it(testLabel, () => { @@ -17,7 +15,7 @@ describe('With type checking', () => { describe('Without type checking', () => { const testCase = configureTestCase('type-checking', { - tsJestConfig: { typeCheck: false }, + tsJestConfig: { isolatedModules: true }, }) testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => { diff --git a/package.json b/package.json index 1d5daacbc7..5a4463ca00 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-jest", - "version": "23.10.0-beta.1", + "version": "23.10.0-beta.2", "main": "dist/index.js", "types": "dist/index.d.ts", "description": "A preprocessor with sourcemap support to help use Typescript with Jest", @@ -11,6 +11,7 @@ "clean": "node scripts/clean.js", "pretest": "npm run 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", diff --git a/src/__helpers__/fakers.ts b/src/__helpers__/fakers.ts index e5e3c0d058..cb8274c7cb 100644 --- a/src/__helpers__/fakers.ts +++ b/src/__helpers__/fakers.ts @@ -56,7 +56,7 @@ describe('hello', () => { export function tsJestConfig(options?: Partial): TsJestConfig { return { - typeCheck: false, + isolatedModules: false, compiler: 'typescript', babelConfig: undefined, tsConfig: undefined, diff --git a/src/compiler.spec.ts b/src/compiler.spec.ts index b450d3003b..ec9f6b8307 100644 --- a/src/compiler.spec.ts +++ b/src/compiler.spec.ts @@ -35,8 +35,8 @@ beforeEach(() => { logTarget.clear() }) -describe('typeCheck', () => { - const compiler = makeCompiler({ tsJestConfig: { typeCheck: true } }) +describe('isolatedModules', () => { + const compiler = makeCompiler() it('should report diagnostics related to typings', () => { expect(() => compiler.compile( @@ -83,9 +83,731 @@ describe('cache', () => { Array [ "[level:20] readThrough(): cache miss ", - "[level:20] getOutput(): compiling as isolated module + "[level:20] getOutput(): compiling using language service +", + "[level:20] updateMemoryCache() +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] readFile +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss +", + "[level:20] getScriptSnapshot(): cache miss ", "[level:20] visitSourceFileNode(): hoisting +", + "[level:20] getOutput(): computing diagnostics +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit +", + "[level:20] getScriptSnapshot(): cache hit ", "[level:20] readThrough(): writing caches ", @@ -123,7 +845,7 @@ Array [ }) describe('getTypeInfo', () => { - const compiler = makeCompiler({ tsJestConfig: { typeCheck: true } }) + const compiler = makeCompiler() const source = ` type MyType { /** the prop 1! */ diff --git a/src/compiler.ts b/src/compiler.ts index 8ec4429f17..f48508a59f 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -51,8 +51,9 @@ export function createCompiler(configs: ConfigSet): TsCompiler { const logger = configs.logger.child({ namespace: 'ts-compiler' }) logger.debug( 'creating typescript compiler', - configs.tsJest.typeCheck ? 'with' : 'without', - 'type-checking', + configs.tsJest.isolatedModules + ? '(isolated modules)' + : '(language service)', ) const cachedir = configs.tsCacheDir @@ -127,7 +128,7 @@ export function createCompiler(configs: ConfigSet): TsCompiler { } // Use full language services when the fast option is disabled. - if (configs.tsJest.typeCheck) { + if (!configs.tsJest.isolatedModules) { // Set the file contents into cache. const updateMemoryCache = (code: string, fileName: string) => { logger.debug({ fileName }, `updateMemoryCache()`) diff --git a/src/config/__snapshots__/config-set.spec.ts.snap b/src/config/__snapshots__/config-set.spec.ts.snap index c315592860..e9be81cad6 100644 --- a/src/config/__snapshots__/config-set.spec.ts.snap +++ b/src/config/__snapshots__/config-set.spec.ts.snap @@ -30,11 +30,11 @@ Object { ], "pretty": true, }, + "isolatedModules": false, "stringifyContentPathRegex": undefined, "tsConfig": Object { "kind": "file", "value": undefined, }, - "typeCheck": false, } `; diff --git a/src/config/config-set.spec.ts b/src/config/config-set.spec.ts index 52af76c2d8..650f3b6a58 100644 --- a/src/config/config-set.spec.ts +++ b/src/config/config-set.spec.ts @@ -192,16 +192,16 @@ describe('tsJest', () => { }) }) // stringifyContentPathRegex - describe('typeCheck', () => { + describe('isolatedModules', () => { it('should be correct for default value', () => { - expect(get().typeCheck).toBe(false) - expect(get({ typeCheck: false }).typeCheck).toBe(false) + expect(get().isolatedModules).toBe(false) + expect(get({ isolatedModules: false }).isolatedModules).toBe(false) }) it('should be normalized to a boolean', () => { - expect(get({ typeCheck: 'yes' as any }).typeCheck).toBe(true) - expect(get({ typeCheck: false }).typeCheck).toBe(false) + expect(get({ isolatedModules: 'yes' as any }).isolatedModules).toBe(true) + expect(get({ isolatedModules: 1 as any }).isolatedModules).toBe(true) }) - }) // typeCheck + }) // isolatedModules describe('compiler', () => { it('should be correct for default value', () => { diff --git a/src/index.spec.ts b/src/index.spec.ts index 8e6929782e..73254b0130 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -64,8 +64,10 @@ describe('createTransformer', () => { expect(tr1).not.toBe(tr2) }) it('should accept base options', () => { - expect((tsJest.createTransformer({ typeCheck: true }) as any).opt).toEqual({ - typeCheck: true, + expect( + (tsJest.createTransformer({ isolatedModules: true }) as any).opt, + ).toEqual({ + isolatedModules: true, }) }) }) diff --git a/src/types.ts b/src/types.ts index 72247f3e4f..8539d8ad91 100644 --- a/src/types.ts +++ b/src/types.ts @@ -23,9 +23,9 @@ export interface TsJestGlobalOptions { tsConfig?: boolean | string | CompilerOptions /** - * Whether to typecheck (slower, default to `false`): + * Whether to compile files as isolated modules (disables some features and type-checking, default to `false`): */ - typeCheck?: boolean + isolatedModules?: boolean /** * Compiler to use (default to 'typescript'): @@ -33,7 +33,7 @@ export interface TsJestGlobalOptions { compiler?: string /** - * TS diagnostics - more to be reported if `typeCheck` is `true`. It can be: + * TS diagnostics - less to be reported if `isolatedModules` is `true`. It can be: * - `true` (or `undefined`, it's the default): show all diagnostics * - `false`: hide diagnostics of all files (kind of useless) * - `{...}`: an inline object with fine grained settings @@ -97,7 +97,7 @@ type TsJestConfig$stringifyContentPathRegex = string | undefined export interface TsJestConfig { tsConfig: TsJestConfig$tsConfig - typeCheck: boolean + isolatedModules: boolean compiler: string diagnostics: TsJestConfig$diagnostics babelConfig: TsJestConfig$babelConfig diff --git a/src/util/__snapshots__/backports.spec.ts.snap b/src/util/__snapshots__/backports.spec.ts.snap index eb5ca9b4de..4a8a35d43a 100644 --- a/src/util/__snapshots__/backports.spec.ts.snap +++ b/src/util/__snapshots__/backports.spec.ts.snap @@ -221,6 +221,56 @@ exports[`backportJestConfig with "globals.ts-jest.tsConfigFile" set to 'tsconfig " `; +exports[`backportJestConfig with "globals.ts-jest.typeCheck" set to false should have changed the config correctly: before 1`] = ` +Object { + "globals": Object { + "ts-jest": Object { + "typeCheck": false, + }, + }, +} +`; + +exports[`backportJestConfig with "globals.ts-jest.typeCheck" set to false should have changed the config correctly: migrated 1`] = ` +Object { + "globals": Object { + "ts-jest": Object { + "isolatedModules": true, + }, + }, +} +`; + +exports[`backportJestConfig with "globals.ts-jest.typeCheck" set to false should wran the user 1`] = ` +"[level:40] \\"[jest-config].globals.ts-jest.typeCheck\\" is deprecated, use \\"[jest-config].globals.ts-jest.isolatedModules\\" instead. +" +`; + +exports[`backportJestConfig with "globals.ts-jest.typeCheck" set to true should have changed the config correctly: before 1`] = ` +Object { + "globals": Object { + "ts-jest": Object { + "typeCheck": true, + }, + }, +} +`; + +exports[`backportJestConfig with "globals.ts-jest.typeCheck" set to true should have changed the config correctly: migrated 1`] = ` +Object { + "globals": Object { + "ts-jest": Object { + "isolatedModules": false, + }, + }, +} +`; + +exports[`backportJestConfig with "globals.ts-jest.typeCheck" set to true should wran the user 1`] = ` +"[level:40] \\"[jest-config].globals.ts-jest.typeCheck\\" is deprecated, use \\"[jest-config].globals.ts-jest.isolatedModules\\" instead. +" +`; + exports[`backportJestConfig with "globals.ts-jest.useBabelrc" set to false should have changed the config correctly: before 1`] = ` Object { "globals": Object { diff --git a/src/util/backports.spec.ts b/src/util/backports.spec.ts index 4e4e6c8e16..b0aec17b83 100644 --- a/src/util/backports.spec.ts +++ b/src/util/backports.spec.ts @@ -58,6 +58,11 @@ describe('backportJestConfig', () => { false, ]) + makeTestsFor('globals.ts-jest.typeCheck', 'globals.ts-jest.isolatedModules', [ + true, + false, + ]) + makeTestsFor('globals.ts-jest.skipBabel', 'globals.ts-jest.babelConfig', [ true, false, diff --git a/src/util/backports.ts b/src/util/backports.ts index 74990983ce..5e5f3ed9a1 100644 --- a/src/util/backports.ts +++ b/src/util/backports.ts @@ -47,6 +47,12 @@ export const backportJestConfig = < delete globals.__TRANSFORM_HTML__ } + if ('typeCheck' in tsJest) { + warnConfig('globals.ts-jest.typeCheck', 'globals.ts-jest.isolatedModules') + mergeTsJest.isolatedModules = !tsJest.typeCheck + delete tsJest.typeCheck + } + if ('tsConfigFile' in tsJest) { warnConfig('globals.ts-jest.tsConfigFile', 'globals.ts-jest.tsConfig') if (tsJest.tsConfigFile) { diff --git a/src/util/messages.ts b/src/util/messages.ts index 49015f031d..7205ede39b 100644 --- a/src/util/messages.ts +++ b/src/util/messages.ts @@ -2,7 +2,7 @@ export enum Errors { UnableToLoadOneModule = 'Unable to load the module {{module}}. {{reason}} To fix it:\n{{fix}}', UnableToLoadAnyModule = 'Unable to load any of these modules: {{module}}. {{reason}}. To fix it:\n{{fix}}', - TypesUnavailableWithoutTypeCheck = 'Type information is unavailable without "typeCheck"', + TypesUnavailableWithoutTypeCheck = 'Type information is unavailable with "isolatedModules"', UnableToRequireDefinitionFile = 'Unable to require `.d.ts` 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}}`.', FileNotFound = 'File not found: {{inputPath}} (resolved as: {{resolvedPath}})', UntestedDependencyVersion = "Version {{actualVersion}} of {{module}} installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version ({{expectedVersion}}). Please do not report issues in ts-jest if you are using unsupported versions.",