Skip to content

Commit

Permalink
fix(jest-runtime): only write map files to disk when `mapCoverage: tr…
Browse files Browse the repository at this point in the history
…ue` (#5117)

* fix(jest-runtime): only write map files to disk when `mapCoverage: true`

* docs: update changelog and run prettier
  • Loading branch information
SimenB authored and cpojer committed Dec 18, 2017
1 parent 9afeb9c commit 5b2ffb5
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 111 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## master

### Fixes

* `[jest-runtime]` fix error for test files providing coverage.
([#5117](https://github.com/facebook/jest/pull/5117))

### Features

* `[jest-config]` Add `forceCoverageMatch` to allow collecting coverage from
ignored files. ([#5081](https://github.com/facebook/jest/pull/5081))

Expand Down
7 changes: 4 additions & 3 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,16 @@ Jest will fail if:
Default: `['']`

Test files are normally ignored from collecting code coverage. With this option,
you can overwrite this behavior and include otherwise ignored files in code coverage.
you can overwrite this behavior and include otherwise ignored files in code
coverage.

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

```javascript
// sum.t.js

export function sum(a,b) {
export function sum(a, b) {
return a + b;
}

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

You can collect coverage from those files with setting `forceCoverageMatch`.

```json
{
...
Expand All @@ -271,7 +273,6 @@ You can collect coverage from those files with setting `forceCoverageMatch`.
}
```


### `globals` [object]

Default: `{}`
Expand Down
106 changes: 64 additions & 42 deletions docs/JestPlatform.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,42 @@ id: jest-platform
title: Jest Platform
---

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

## jest-changed-files

Tool for identifying modified files in a git/hg repository. Exports two functions:
Tool for identifying modified files in a git/hg repository. Exports two
functions:

- `getChangedFilesForRoots` returns a promise that resolves to an object with the changed files and repos.
- `findRepos` returns a promise that resolves to a set of repositories contained in the specified path.
* `getChangedFilesForRoots` returns a promise that resolves to an object with
the changed files and repos.
* `findRepos` returns a promise that resolves to a set of repositories contained
in the specified path.

### Example

``` javascript
const {getChangedFilesForRoots} = require( 'jest-changed-files');
```javascript
const {getChangedFilesForRoots} = require('jest-changed-files');

// print the set of modified files since last commit in the current repo
getChangedFilesForRoots(['./'], {
lastCommit: true,
}).then(result => console.log(result.changedFiles));

```

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).
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).

## jest-diff

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.
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.

### Example

``` javascript
```javascript
const diff = require('jest-diff');

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

## jest-docblock

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.
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.

### Example

``` javascript
const { parseWithComments } = require('jest-docblock');
```javascript
const {parseWithComments} = require('jest-docblock');

const code = `
/**
Expand All @@ -66,17 +73,20 @@ const code = `
const parsed = parseWithComments(code);

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

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

## jest-get-type

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.
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.

### Example

``` javascript
```javascript
const getType = require('jest-get-type');

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

## jest-validate

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:
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:

- `hasDeprecationWarnings`, a boolean indicating whether the submitted configuration has deprecation warnings,
- `isValid`, a boolean indicating whether the configuration is correct or not.
* `hasDeprecationWarnings`, a boolean indicating whether the submitted
configuration has deprecation warnings,
* `isValid`, a boolean indicating whether the configuration is correct or not.

### Example
### Example

``` javascript
const { validate } = require('jest-validate');
```javascript
const {validate} = require('jest-validate');

const configByUser = {
transform: '<rootDir>/node_modules/my-custom-transform'
}
transform: '<rootDir>/node_modules/my-custom-transform',
};

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

console.log(result);
```

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

## jest-worker

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.
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.

### Example
### Example

``` javascript
```javascript
// heavy-task.js

module.exports = {
myHeavyTask: (args) => {
myHeavyTask: args => {
// long running CPU intensive task.
}
}
},
};
```

``` javascript
```javascript
// main.js

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

// run 2 tasks in parellel with different arguments
const results = await Promise.all([
worker.myHeavyTask({ foo: 'bar' }),
worker.myHeavyTask({bar: 'foo' }),
]);
worker.myHeavyTask({foo: 'bar'}),
worker.myHeavyTask({bar: 'foo'}),
]);

console.log(results);
}

main();
```

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

## pretty-format

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.
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.

### Example

``` javascript
const prettyFormat = require('pretty-format');
```javascript
const prettyFormat = require('pretty-format');

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

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

0 comments on commit 5b2ffb5

Please sign in to comment.