Skip to content

Commit

Permalink
Documentation updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer committed May 4, 2017
1 parent 79dfafd commit 7ccd640
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 10 deletions.
8 changes: 7 additions & 1 deletion docs/en/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ permalink: docs/en/cli.html
previous: configuration
---

The `jest` command line runner has a number of useful options. You can run `jest --help` to view all available options. Many of the options shown below can also be used together to run tests exactly the way you want. Here is a brief overview:
The `jest` command line runner has a number of useful options. You can run `jest --help` to view all available options. Many of the options shown below can also be used together to run tests exactly the way you want. Every one of Jest's [Configuration](/jest/docs/configuration.html) options can also be specified through the CLI.

Here is a brief overview:

## Running from the command line

Expand Down Expand Up @@ -81,6 +83,10 @@ Alias: `-b`. Exit the test suite immediately upon the first failing test suite.

Whether to use the cache. Defaults to true. Disable the cache using `--no-cache`. *Note: the cache should only be disabled if you are experiencing caching related problems. On average, disabling the cache makes Jest at least two times slower.*

### `--ci`

When this option is provided, Jest will assume it is running in a CI environment. This changes the behavior when a new snapshot is encountered. Instead of the regular behavior of storing a new snapshot automatically, it will fail the test and require Jest to be run with `--updateSnapshot`.

### `--collectCoverageFrom=<glob>`

Relative to the root directory, glob pattern matching the files that coverage info needs to be collected from.
Expand Down
30 changes: 28 additions & 2 deletions docs/en/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ previous: jest-object
next: cli
---

Jest's configuration can be defined in the `package.json` file of your project
or through the `--config <path/to/json>` option. If you'd like to use
Jest's configuration can be defined in the `package.json` file of your project, through a `jest.config.js` file or
or through the `--config <path/to/js|json>` option. If you'd like to use
your `package.json` to store Jest's config, the "jest" key should be used on the
top level so Jest will know how to find your settings:

Expand All @@ -22,6 +22,16 @@ top level so Jest will know how to find your settings:
}
```

Or through JavaScript:

```js
module.exports = {
verbose: true,
};
```

Please keep in mind that the resulting configuration must be JSON-serializable.

When using the --config option, the JSON file must not contain a "jest" key:

```json
Expand Down Expand Up @@ -231,6 +241,22 @@ Default: `undefined`

A preset that is used as a base for Jest's configuration. A preset should point to an npm module that exports a `jest-preset.json` module on its top level.

### `projects` [array<string>]
Default: `undefined`

When the `projects` configuration is provided with an array of paths or glob patterns, Jest will run tests in all of the specified projects at the same time. This is great for monorepos or when working on multiple projects at the same time.

```json
{
"projects": [
"<rootDir>",
"<rootDir>/examples/*"
]
}
```

This example configuration will run Jest in the root directory as well as in every folder in the examples directory. You can have an unlimited amount of projects running in the same Jest instance.

### `clearMocks` [boolean]
Default: `false`

Expand Down
4 changes: 4 additions & 0 deletions docs/en/SnapshotTesting.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ Date.now = jest.fn(() => 1482363367071);

Now, every time the snapshot test case runs, `Date.now()` will return `1482363367071` consistently. This will result in the same snapshot being generated for this component regardless of when the test is run.

### Snapshots are not written automatically on Continuous Integration systems (CI)

As of Jest 20, snapshots in Jest are not automatically written when Jest is run in a CI system without explicitly passing `--updateSnapshot`. It is expected that all snapshots are part of the code that is run on CI and since new snapshots automatically pass, they should not pass a test run on a CI system. It is recommended to always commit all snapshots and to keep them in version control.

## Frequently Asked Questions

### Should snapshot files be committed?
Expand Down
16 changes: 9 additions & 7 deletions packages/jest-cli/src/cli/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ const options = {
},
browser: {
default: undefined,
description: 'Respect Browserify\'s "browser" field in package.json ' +
'when resolving modules. Some modules export different versions ' +
'based on whether they are operating in Node or a browser.',
description: 'Respect the "browser" field in package.json ' +
'when resolving modules. Some packages export different versions ' +
'based on whether they are operating in node.js or a browser.',
type: 'boolean',
},
cache: {
Expand Down Expand Up @@ -106,7 +106,7 @@ const options = {
type: 'string',
},
collectCoverageOnlyFrom: {
description: 'List of paths coverage will be restricted to.',
description: 'Explicit list of paths coverage will be restricted to.',
type: 'array',
},
color: {
Expand Down Expand Up @@ -191,8 +191,8 @@ const options = {
type: 'string',
},
haste: {
description: "A JSON string with map of variables for Facebook's " +
'@providesModule module system',
description: 'A JSON string with map of variables for the haste ' +
' module system',
type: 'string',
},
json: {
Expand All @@ -209,7 +209,9 @@ const options = {
},
listTests: {
default: false,
description: 'Lists all tests Jest will run given the arguments and exits.',
description: 'Lists all tests Jest will run given the arguments and ' +
'exits. Most useful in a CI system together with `--findRelatedTests` ' +
'to determine the tests Jest will run based on specific files',
type: 'boolean',
},
logHeapUsage: {
Expand Down

0 comments on commit 7ccd640

Please sign in to comment.