From b4c6332053551b165dd523df3f5ae2655688927c Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 17 Feb 2020 22:20:22 -0800 Subject: [PATCH] Allow instrumentation of transformed files with weird file extensions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default configuration of babel-plugin-istanbul only allows instrumentation of files with extensions .js, .cjs, .mjs, .ts, .tsx, .jsx (https://github.com/istanbuljs/schema/blob/v0.1.2/index.js#L71). However, we know that we’re running it on code that we just transformed to JavaScript, so the source language no longer matters, and we should disable this check to get complete instrumentation. Signed-off-by: Anders Kaseorg --- CHANGELOG.md | 1 + packages/jest-transform/src/ScriptTransformer.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ce5d755682a..dae229790967 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - `[jest-snapshot]` Downgrade semver to v6 to support node 8 ([#9451](https://github.com/facebook/jest/pull/9451)) - `[jest-snapshot]` Properly indent new snapshots in the presences of existing ones ([#9523](https://github.com/facebook/jest/pull/9523)) - `[jest-transform]` Correct sourcemap behavior for transformed and instrumented code ([#9460](https://github.com/facebook/jest/pull/9460)) +- `[jest-transform]` Allow instrumentation of transformed files with weird file extensions ([#9589](https://github.com/facebook/jest/pull/9589)) - `[pretty-format]` Export `OldPlugin` type ([#9491](https://github.com/facebook/jest/pull/9491)) ### Chore & Maintenance diff --git a/packages/jest-transform/src/ScriptTransformer.ts b/packages/jest-transform/src/ScriptTransformer.ts index 8d6a06637be7..18b3b46a07f0 100644 --- a/packages/jest-transform/src/ScriptTransformer.ts +++ b/packages/jest-transform/src/ScriptTransformer.ts @@ -213,6 +213,7 @@ export default class ScriptTransformer { // files outside `cwd` will not be instrumented cwd: this._config.rootDir, exclude: [], + extension: false, // Needed for correct coverage as soon as we start storing a source map of the instrumented code inputSourceMap: input.map, useInlineSourceMaps: false,