-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Removing the mapCoverage condition on reading inlineSourceMaps. #5177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
00cb000
f927798
fdefcaa
c1f6712
970c94f
5f17ea3
936c4cc
62f3b31
520a141
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,12 @@ | |
| */ | ||
|
|
||
| import type {Path, ProjectConfig} from 'types/Config'; | ||
| import type {CacheKeyOptions, TransformOptions} from 'types/Transform'; | ||
| import type { | ||
| CacheKeyOptions, | ||
| Transformer, | ||
| TransformOptions, | ||
| TransformedSource, | ||
| } from 'types/Transform'; | ||
|
|
||
| import crypto from 'crypto'; | ||
| import fs from 'fs'; | ||
|
|
@@ -23,7 +28,7 @@ const BABEL_CONFIG_KEY = 'babel'; | |
| const PACKAGE_JSON = 'package.json'; | ||
| const THIS_FILE = fs.readFileSync(__filename); | ||
|
|
||
| const createTransformer = (options: any) => { | ||
| const createTransformer = (options: any): Transformer => { | ||
| const cache = Object.create(null); | ||
|
|
||
| const getBabelRC = filename => { | ||
|
|
@@ -69,8 +74,6 @@ const createTransformer = (options: any) => { | |
| options = Object.assign({}, options, { | ||
| plugins: (options && options.plugins) || [], | ||
| presets: ((options && options.presets) || []).concat([jestPreset]), | ||
| retainLines: true, | ||
| sourceMaps: 'inline', | ||
| }); | ||
| delete options.cacheDirectory; | ||
| delete options.filename; | ||
|
|
@@ -102,16 +105,23 @@ const createTransformer = (options: any) => { | |
| src: string, | ||
| filename: Path, | ||
| config: ProjectConfig, | ||
| transformOptions: TransformOptions, | ||
| ): string { | ||
| transformOptions?: TransformOptions, | ||
| ): string | TransformedSource { | ||
| const altExts = config.moduleFileExtensions.map( | ||
| extension => '.' + extension, | ||
| ); | ||
| const shouldUseInline = | ||
|
||
| transformOptions && | ||
| (transformOptions.returnSourceString == null || | ||
| transformOptions.returnSourceString); | ||
| const sourceMapOpts = { | ||
| sourceMaps: shouldUseInline ? 'inline' : true, | ||
| }; | ||
| if (babelUtil && !babelUtil.canCompile(filename, altExts)) { | ||
| return src; | ||
| } | ||
|
|
||
| const theseOptions = Object.assign({filename}, options); | ||
| const theseOptions = Object.assign({filename}, options, sourceMapOpts); | ||
| if (transformOptions && transformOptions.instrument) { | ||
| theseOptions.auxiliaryCommentBefore = ' istanbul ignore next '; | ||
| // Copied from jest-runtime transform.js | ||
|
|
@@ -129,7 +139,12 @@ const createTransformer = (options: any) => { | |
|
|
||
| // babel v7 might return null in the case when the file has been ignored. | ||
| const transformResult = babelTransform(src, theseOptions); | ||
| return transformResult ? transformResult.code : src; | ||
|
|
||
| if (!transformResult) { | ||
| return src; | ||
| } | ||
|
|
||
| return shouldUseInline ? transformResult.code : transformResult; | ||
| }, | ||
| }; | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,7 +83,15 @@ export default class CoverageReporter extends BaseReporter { | |
| await this._addUntestedFiles(this._globalConfig, contexts); | ||
| let map = this._coverageMap; | ||
| let sourceFinder: Object; | ||
| ({map, sourceFinder} = this._sourceMapStore.transformCoverage(map)); //eslint-disable-line | ||
| const transformedCoverage = this._sourceMapStore.transformCoverage(map); | ||
|
||
|
|
||
| if ( | ||
| transformedCoverage.map && | ||
| transformedCoverage.map.data && | ||
| Object.keys(transformedCoverage.map.data).length > 0 | ||
| ) { | ||
| ({map, sourceFinder} = transformedCoverage); | ||
| } | ||
|
|
||
| const reporter = createReporter(); | ||
| try { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
retainLinesneeds to remain for now. We'll look into removing it after getting this merged