From 254c619c5ea8da9157bd9141fbf3564581840133 Mon Sep 17 00:00:00 2001 From: Justin Bay Date: Thu, 23 Feb 2017 20:00:01 -0500 Subject: [PATCH] tweak docs, fix a test --- docs/Configuration.md | 10 +++++----- .../jest-runtime/src/__tests__/transform-test.js | 12 ++++++------ types/TestResult.js | 1 - 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/docs/Configuration.md b/docs/Configuration.md index 06c5e104c130..b79928832c94 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -152,18 +152,18 @@ Note that, if you specify a global reference value (like an object or array) her ### `mapCoverage` [boolean] -##### available in Jest **19.0.0+** +##### available in Jest **20.0.0+** Default: `false` -If you have [transformers](#transform-object-string-string) configured that emit source maps, Jest will use them to map code coverage against the original source code when writing [reports](#coveragereporters-array-string) and checking [thresholds](#coveragethreshold-object). This can be resource-intensive. If Jest is taking a long time to calculate coverage at the end of a test run, try setting this option to `false`. +If you have [transformers](#transform-object-string-string) configured that emit source maps, Jest will use them to try and map code coverage against the original source code when writing [reports](#coveragereporters-array-string) and checking [thresholds](#coveragethreshold-object). This is done on a best-effort basis as some compile-to-JavaScript languages may provide more accurate source maps than others. This can also be resource-intensive. If Jest is taking a long time to calculate coverage at the end of a test run, try setting this option to `false`. -Both inline source maps and source maps returned directly from a transformer are supported. Source map URLs are not supported because Jest may not be able to locate them. To return source maps from a transformer, the `process` function can return an object like the following. The sourceMap property may either be an object, or a string of JSON. +Both inline source maps and source maps returned directly from a transformer are supported. Source map URLs are not supported because Jest may not be able to locate them. To return source maps from a transformer, the `process` function can return an object like the following. The `map` property may either be the source map object, or the source map object as a JSON string. ```js return { - content: 'the code', - sourceMap: 'the source map', + code: 'the code', + map: 'the source map', }; ``` diff --git a/packages/jest-runtime/src/__tests__/transform-test.js b/packages/jest-runtime/src/__tests__/transform-test.js index 1e005840e673..23663b9f5eda 100644 --- a/packages/jest-runtime/src/__tests__/transform-test.js +++ b/packages/jest-runtime/src/__tests__/transform-test.js @@ -226,7 +226,7 @@ describe('transform', () => { expect(vm.Script.mock.calls[2][0]).toMatchSnapshot(); }); - it('instruments with source map if preprocessor supplies it', () => { + it('writes source map if preprocessor supplies it', () => { config = Object.assign(config, { collectCoverage: true, mapCoverage: true, @@ -252,7 +252,7 @@ describe('transform', () => { ); }); - it('instruments with source map if preprocessor inlines it', () => { + it('writes source map if preprocessor inlines it', () => { config = Object.assign(config, { collectCoverage: true, mapCoverage: true, @@ -279,21 +279,21 @@ describe('transform', () => { ); }); - it('does not instrument with source map if mapCoverage config option is false', () => { + it('does not write source map if mapCoverage config option is false', () => { config = Object.assign(config, { collectCoverage: true, mapCoverage: false, transform: [['^.+\\.js$', 'preprocessor-with-sourcemaps']], }); - const sourceMap = { + const map = { mappings: ';AAAA', version: 3, }; require('preprocessor-with-sourcemaps').process.mockReturnValue({ - content: 'content', - sourceMap, + code: 'content', + map, }); const result = transform('/fruits/banana.js', config); diff --git a/types/TestResult.js b/types/TestResult.js index d78ae4cf1f46..34fbfad28e45 100644 --- a/types/TestResult.js +++ b/types/TestResult.js @@ -21,7 +21,6 @@ export type RawFileCoverage = {| statementMap: { [statementId: number]: any }, branchMap: { [branchId: number]: any }, inputSourceMap?: Object, - inputSourceMapPath?: string, |}; export type RawCoverage = {