Skip to content

Commit

Permalink
tweak docs, fix a test
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbay committed Feb 24, 2017
1 parent 6a3ac5d commit 254c619
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
10 changes: 5 additions & 5 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};
```

Expand Down
12 changes: 6 additions & 6 deletions packages/jest-runtime/src/__tests__/transform-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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);
Expand Down
1 change: 0 additions & 1 deletion types/TestResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export type RawFileCoverage = {|
statementMap: { [statementId: number]: any },
branchMap: { [branchId: number]: any },
inputSourceMap?: Object,
inputSourceMapPath?: string,
|};

export type RawCoverage = {
Expand Down

0 comments on commit 254c619

Please sign in to comment.