Skip to content

Commit 5b2ffb5

Browse files
SimenBcpojer
authored andcommitted
fix(jest-runtime): only write map files to disk when mapCoverage: true (#5117)
* fix(jest-runtime): only write map files to disk when `mapCoverage: true` * docs: update changelog and run prettier
1 parent 9afeb9c commit 5b2ffb5

File tree

7 files changed

+135
-111
lines changed

7 files changed

+135
-111
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
## master
22

3+
### Fixes
4+
5+
* `[jest-runtime]` fix error for test files providing coverage.
6+
([#5117](https://github.com/facebook/jest/pull/5117))
7+
8+
### Features
9+
310
* `[jest-config]` Add `forceCoverageMatch` to allow collecting coverage from
411
ignored files. ([#5081](https://github.com/facebook/jest/pull/5081))
512

docs/Configuration.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,16 @@ Jest will fail if:
242242
Default: `['']`
243243

244244
Test files are normally ignored from collecting code coverage. With this option,
245-
you can overwrite this behavior and include otherwise ignored files in code coverage.
245+
you can overwrite this behavior and include otherwise ignored files in code
246+
coverage.
246247

247248
For example, if you have tests in source files named with `.t.js` extension as
248249
following:
249250

250251
```javascript
251252
// sum.t.js
252253

253-
export function sum(a,b) {
254+
export function sum(a, b) {
254255
return a + b;
255256
}
256257

@@ -262,6 +263,7 @@ if (process.env.NODE_ENV === 'test') {
262263
```
263264

264265
You can collect coverage from those files with setting `forceCoverageMatch`.
266+
265267
```json
266268
{
267269
...
@@ -271,7 +273,6 @@ You can collect coverage from those files with setting `forceCoverageMatch`.
271273
}
272274
```
273275

274-
275276
### `globals` [object]
276277

277278
Default: `{}`

docs/JestPlatform.md

Lines changed: 64 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,42 @@ id: jest-platform
33
title: Jest Platform
44
---
55

6-
You can cherry pick specific features of Jest and use them as standalone packages. Here's a list of the available packages:
6+
You can cherry pick specific features of Jest and use them as standalone
7+
packages. Here's a list of the available packages:
78

89
## jest-changed-files
910

10-
Tool for identifying modified files in a git/hg repository. Exports two functions:
11+
Tool for identifying modified files in a git/hg repository. Exports two
12+
functions:
1113

12-
- `getChangedFilesForRoots` returns a promise that resolves to an object with the changed files and repos.
13-
- `findRepos` returns a promise that resolves to a set of repositories contained in the specified path.
14+
* `getChangedFilesForRoots` returns a promise that resolves to an object with
15+
the changed files and repos.
16+
* `findRepos` returns a promise that resolves to a set of repositories contained
17+
in the specified path.
1418

1519
### Example
1620

17-
``` javascript
18-
const {getChangedFilesForRoots} = require( 'jest-changed-files');
21+
```javascript
22+
const {getChangedFilesForRoots} = require('jest-changed-files');
1923

2024
// print the set of modified files since last commit in the current repo
2125
getChangedFilesForRoots(['./'], {
2226
lastCommit: true,
2327
}).then(result => console.log(result.changedFiles));
24-
2528
```
2629

27-
You can read more about `jest-changed-files` in the [readme file](https://github.com/facebook/jest/blob/master/packages/jest-changed-files/README.md).
30+
You can read more about `jest-changed-files` in the
31+
[readme file](https://github.com/facebook/jest/blob/master/packages/jest-changed-files/README.md).
2832

2933
## jest-diff
3034

31-
Tool for visualizing changes in data. Exports a function that compares two values of any type and returns a "pretty-printed" string illustrating the difference between the two arguments.
35+
Tool for visualizing changes in data. Exports a function that compares two
36+
values of any type and returns a "pretty-printed" string illustrating the
37+
difference between the two arguments.
3238

3339
### Example
3440

35-
``` javascript
41+
```javascript
3642
const diff = require('jest-diff');
3743

3844
const a = {a: {b: {c: 5}}};
@@ -46,12 +52,13 @@ console.log(result);
4652

4753
## jest-docblock
4854

49-
Tool for extracting and parsing the comments at the top of a JavaScript file. Exports various function to manipulate the data inside the comment block.
55+
Tool for extracting and parsing the comments at the top of a JavaScript file.
56+
Exports various function to manipulate the data inside the comment block.
5057

5158
### Example
5259

53-
``` javascript
54-
const { parseWithComments } = require('jest-docblock');
60+
```javascript
61+
const {parseWithComments} = require('jest-docblock');
5562

5663
const code = `
5764
/**
@@ -66,17 +73,20 @@ const code = `
6673
const parsed = parseWithComments(code);
6774

6875
// prints an object with two attributes: comments and pragmas.
69-
console.log(parsed)
76+
console.log(parsed);
7077
```
71-
You can read more about `jest-docblock` in the [readme file](https://github.com/facebook/jest/blob/master/packages/jest-docblock/README.md).
78+
79+
You can read more about `jest-docblock` in the
80+
[readme file](https://github.com/facebook/jest/blob/master/packages/jest-docblock/README.md).
7281

7382
## jest-get-type
7483

75-
Module that identifies the primitive type of any JavaScript value. Exports a function that returns a string with the type of the value passed as argument.
84+
Module that identifies the primitive type of any JavaScript value. Exports a
85+
function that returns a string with the type of the value passed as argument.
7686

7787
### Example
7888

79-
``` javascript
89+
```javascript
8090
const getType = require('jest-get-type');
8191

8292
const array = [1, 2, 3];
@@ -93,74 +103,85 @@ console.log(getType(undefinedValue));
93103

94104
## jest-validate
95105

96-
Tool for validating configurations submitted by users. Exports a function that takes two arguments: the user's configuration and an object containing an example configuration and other options. The return value is an object with two attributes:
106+
Tool for validating configurations submitted by users. Exports a function that
107+
takes two arguments: the user's configuration and an object containing an
108+
example configuration and other options. The return value is an object with two
109+
attributes:
97110

98-
- `hasDeprecationWarnings`, a boolean indicating whether the submitted configuration has deprecation warnings,
99-
- `isValid`, a boolean indicating whether the configuration is correct or not.
111+
* `hasDeprecationWarnings`, a boolean indicating whether the submitted
112+
configuration has deprecation warnings,
113+
* `isValid`, a boolean indicating whether the configuration is correct or not.
100114

101-
### Example
115+
### Example
102116

103-
``` javascript
104-
const { validate } = require('jest-validate');
117+
```javascript
118+
const {validate} = require('jest-validate');
105119

106120
const configByUser = {
107-
transform: '<rootDir>/node_modules/my-custom-transform'
108-
}
121+
transform: '<rootDir>/node_modules/my-custom-transform',
122+
};
109123

110124
const result = validate(configByUser, {
111125
comment: ' Documentation: http://custom-docs.com',
112-
exampleConfig: { transform: '<rootDir>/node_modules/babel-jest' },
126+
exampleConfig: {transform: '<rootDir>/node_modules/babel-jest'},
113127
});
114128

115129
console.log(result);
116130
```
117131

118-
You can read more about `jest-validate` in the [readme file](https://github.com/facebook/jest/blob/master/packages/jest-validate/README.md).
132+
You can read more about `jest-validate` in the
133+
[readme file](https://github.com/facebook/jest/blob/master/packages/jest-validate/README.md).
119134

120135
## jest-worker
121136

122-
Module used for parallelization of tasks. Exports a class `Worker` that takes the path of Node.js module and lets you call the module's exported methods as if they where class methods, returning a promise that resolves when the specified method finishes its execution in a forked process.
137+
Module used for parallelization of tasks. Exports a class `Worker` that takes
138+
the path of Node.js module and lets you call the module's exported methods as if
139+
they where class methods, returning a promise that resolves when the specified
140+
method finishes its execution in a forked process.
123141

124-
### Example
142+
### Example
125143

126-
``` javascript
144+
```javascript
127145
// heavy-task.js
128146

129147
module.exports = {
130-
myHeavyTask: (args) => {
148+
myHeavyTask: args => {
131149
// long running CPU intensive task.
132-
}
133-
}
150+
},
151+
};
134152
```
135153

136-
``` javascript
154+
```javascript
137155
// main.js
138156

139157
async function main() {
140158
const worker = new Worker(require.resolve('./heavy-task.js'));
141159

142160
// run 2 tasks in parellel with different arguments
143161
const results = await Promise.all([
144-
worker.myHeavyTask({ foo: 'bar' }),
145-
worker.myHeavyTask({bar: 'foo' }),
146-
]);
162+
worker.myHeavyTask({foo: 'bar'}),
163+
worker.myHeavyTask({bar: 'foo'}),
164+
]);
147165

148166
console.log(results);
149167
}
150168

151169
main();
152170
```
153171

154-
You can read more about `jest-worker` in the [readme file](https://github.com/facebook/jest/blob/master/packages/jest-worker/README.md).
172+
You can read more about `jest-worker` in the
173+
[readme file](https://github.com/facebook/jest/blob/master/packages/jest-worker/README.md).
155174

156175
## pretty-format
157176

158-
Exports a function that converts any JavaScript value into a human-readable string. Supports all built-in JavaScript types out of the box and allows extension for application-specific types via user-defined plugins.
177+
Exports a function that converts any JavaScript value into a human-readable
178+
string. Supports all built-in JavaScript types out of the box and allows
179+
extension for application-specific types via user-defined plugins.
159180

160181
### Example
161182

162-
``` javascript
163-
const prettyFormat = require('pretty-format');
183+
```javascript
184+
const prettyFormat = require('pretty-format');
164185

165186
const val = {object: {}};
166187
val.circularReference = val;
@@ -171,4 +192,5 @@ val.array = [-0, Infinity, NaN];
171192
console.log(prettyFormat(val));
172193
```
173194

174-
You can read more about `pretty-format` in the [readme file](https://github.com/facebook/jest/blob/master/packages/pretty-format/README.md).
195+
You can read more about `pretty-format` in the
196+
[readme file](https://github.com/facebook/jest/blob/master/packages/pretty-format/README.md).

0 commit comments

Comments
 (0)