diff --git a/CHANGELOG.md b/CHANGELOG.md index b70d0be6cf..cc7b7d8a66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## [26.5.5](https://github.com/kulshekhar/ts-jest/compare/v26.5.4...v26.5.5) (2021-04-15) + + +### Bug Fixes + +* **compiler:** return file content on emitSkipped for non ts/tsx files ([#2515](https://github.com/kulshekhar/ts-jest/issues/2515)) ([0320fb3](https://github.com/kulshekhar/ts-jest/commit/0320fb3ac22056aafe4d7ae966eab84dbf23fda9)), closes [#2513](https://github.com/kulshekhar/ts-jest/issues/2513) + + + ## [26.5.4](https://github.com/kulshekhar/ts-jest/compare/v26.5.3...v26.5.4) (2021-03-17) diff --git a/e2e/__templates__/with-babel-7-string-config/package-lock.json b/e2e/__templates__/with-babel-7-string-config/package-lock.json index 57a123c2cf..f4b7894255 100644 --- a/e2e/__templates__/with-babel-7-string-config/package-lock.json +++ b/e2e/__templates__/with-babel-7-string-config/package-lock.json @@ -2112,9 +2112,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001150", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001150.tgz", - "integrity": "sha512-kiNKvihW0m36UhAFnl7bOAv0i1K1f6wpfVtTF5O5O82XzgtBnb05V0XeV3oZ968vfg2sRNChsHw8ASH2hDfoYQ==", + "version": "1.0.30001208", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001208.tgz", + "integrity": "sha512-OE5UE4+nBOro8Dyvv0lfx+SRtfVIOM9uhKqFmJeUbGriqhhStgp1A0OyBpgy3OUF8AhYCT+PVwPC1gMl2ZcQMA==", "dev": true }, "capture-exit": { diff --git a/e2e/__templates__/with-babel-7/package-lock.json b/e2e/__templates__/with-babel-7/package-lock.json index 478ca9f1a1..56b8b5e63d 100644 --- a/e2e/__templates__/with-babel-7/package-lock.json +++ b/e2e/__templates__/with-babel-7/package-lock.json @@ -2112,9 +2112,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001150", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001150.tgz", - "integrity": "sha512-kiNKvihW0m36UhAFnl7bOAv0i1K1f6wpfVtTF5O5O82XzgtBnb05V0XeV3oZ968vfg2sRNChsHw8ASH2hDfoYQ==", + "version": "1.0.30001208", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001208.tgz", + "integrity": "sha512-OE5UE4+nBOro8Dyvv0lfx+SRtfVIOM9uhKqFmJeUbGriqhhStgp1A0OyBpgy3OUF8AhYCT+PVwPC1gMl2ZcQMA==", "dev": true }, "capture-exit": { diff --git a/package.json b/package.json index 131140d6ed..3774e2c86d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-jest", - "version": "26.5.4", + "version": "26.5.5", "main": "dist/index.js", "types": "dist/index.d.ts", "bin": { diff --git a/src/compiler/language-service.ts b/src/compiler/language-service.ts index 3f925b3853..bbcadfc2fd 100644 --- a/src/compiler/language-service.ts +++ b/src/compiler/language-service.ts @@ -260,9 +260,13 @@ export const initializeLanguageServiceInstance = (configs: ConfigSet, logger: Lo } /* istanbul ignore next (this should never happen but is kept for security) */ if (output.emitSkipped) { - logger.warn(interpolate(Errors.CannotProcessFile, { file: fileName })) + if (TS_TSX_REGEX.test(fileName)) { + throw new Error(interpolate(Errors.CannotProcessFile, { file: fileName })) + } else { + logger.warn(interpolate(Errors.CannotProcessFileReturnOriginal, { file: fileName })) - return [code, '{}'] + return [code, '{}'] + } } // Throw an error when requiring `.d.ts` files. if (!output.outputFiles.length) { diff --git a/src/utils/messages.ts b/src/utils/messages.ts index fbde27f389..935aa13de7 100644 --- a/src/utils/messages.ts +++ b/src/utils/messages.ts @@ -17,7 +17,8 @@ export const enum Errors { GotUnknownFileTypeWithBabel = 'Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore. If you still want Babel to process it, add another entry to the `transform` option with value `babel-jest` which key matches this type of files.', ConfigNoModuleInterop = 'If you have issues related to imports, you should consider setting `esModuleInterop` to `true` in your TypeScript configuration file (usually `tsconfig.json`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information.', MismatchNodeTargetMapping = 'There is a mismatch between your NodeJs version {{nodeJsVer}} and your TypeScript target {{compilationTarget}}. This might lead to some unexpected errors when running tests with `ts-jest`. To fix this, you can check https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping', - CannotProcessFile = "Unable to process '{{file}}', falling back to original file content. Please make sure that `outDir` in your tsconfig is neither `''` or `'.'`. You can also configure Jest config option `transformIgnorePatterns` to ignore {{file}} from transformation", + CannotProcessFileReturnOriginal = "Unable to process '{{file}}', falling back to original file content. You can also configure Jest config option `transformIgnorePatterns` to ignore {{file}} from transformation or make sure that `outDir` in your tsconfig is neither `''` or `'.'`", + CannotProcessFile = "Unable to process '{{file}}', please make sure that `outDir` in your tsconfig is neither `''` or `'.'`. You can also configure Jest config option `transformIgnorePatterns` to inform `ts-jest` to transform {{file}}", } /**