Skip to content

Commit a471551

Browse files
authored
chore(docs): cleanup unnecessarily diverging docs (#10691)
1 parent f84a807 commit a471551

File tree

129 files changed

+1416
-13900
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+1416
-13900
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Install Jest using [`yarn`](https://yarnpkg.com/en/package/jest):
5252
yarn add --dev jest
5353
```
5454

55-
Or [`npm`](https://www.npmjs.com/):
55+
Or [`npm`](https://www.npmjs.com/package/jest):
5656

5757
```bash
5858
npm install --save-dev jest
@@ -124,13 +124,13 @@ jest --init
124124

125125
### Using Babel
126126

127-
To use [Babel](http://babeljs.io/), install required dependencies via `yarn`:
127+
To use [Babel](https://babeljs.io/), install required dependencies via `yarn`:
128128

129129
```bash
130130
yarn add --dev babel-jest @babel/core @babel/preset-env
131131
```
132132

133-
If you do not already have babel configured for your project, you can use Babel to target your current version of Node by creating a `babel.config.js` file in the root of your project:
133+
Configure Babel to target your current version of Node by creating a `babel.config.js` file in the root of your project:
134134

135135
```javascript
136136
// babel.config.js
@@ -176,7 +176,7 @@ Jest can be used in projects that use [webpack](https://webpack.js.org/) to mana
176176

177177
### Using parcel
178178

179-
Jest can be used in projects that use [parcel-bundler](https://parceljs.org/) to manage assets, styles, and compilation similar to webpack. Parcel requires zero configuration.
179+
Jest can be used in projects that use [parcel-bundler](https://parceljs.org/) to manage assets, styles, and compilation similar to webpack. Parcel requires zero configuration. Refer to the official [docs](https://parceljs.org/getting_started.html) to get started.
180180

181181
### Using TypeScript
182182

@@ -198,7 +198,7 @@ module.exports = {
198198
};
199199
```
200200

201-
Note, there are some [caveats](https://babeljs.io/docs/en/next/babel-plugin-transform-typescript.html#caveats) to using TypeScript with Babel. Because TypeScript support in Babel is transpilation, Jest will not type-check your tests as they are run. If you want that, you can use [ts-jest](https://github.com/kulshekhar/ts-jest).
201+
However, there are some [caveats](https://babeljs.io/docs/en/babel-plugin-transform-typescript#caveats) to using TypeScript with Babel. Because TypeScript support in Babel is transpilation, Jest will not type-check your tests as they are run. If you want that, you can use [ts-jest](https://github.com/kulshekhar/ts-jest).
202202

203203
<!-- end copied -->
204204

docs/CLI.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Runs tests related to the current changes and the changes made in the last commi
126126

127127
### `--changedSince`
128128

129-
Runs tests related to the changes since the provided branch. If the current branch has diverged from the given branch, then only changes made locally will be tested. Behaves similarly to `--onlyChanged`.
129+
Runs tests related to the changes since the provided branch or commit hash. If the current branch has diverged from the given branch, then only changes made locally will be tested. Behaves similarly to `--onlyChanged`.
130130

131131
### `--ci`
132132

docs/Configuration.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Automatically clear mock calls and instances before every test. Equivalent to ca
151151

152152
Default: `false`
153153

154-
Indicates whether the coverage information should be collected while executing the test. Because these retrofits all executed files with coverage collection statements, it may significantly slow down your tests.
154+
Indicates whether the coverage information should be collected while executing the test. Because this retrofits all executed files with coverage collection statements, it may significantly slow down your tests.
155155

156156
### `collectCoverageFrom` [array]
157157

@@ -989,7 +989,7 @@ You can create your own module that will be used for setting up the test environ
989989

990990
The class may optionally expose an asynchronous `handleTestEvent` method to bind to events fired by [`jest-circus`](https://github.com/facebook/jest/tree/master/packages/jest-circus). Normally, `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled, **except for the next events**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions](https://github.com/facebook/jest/tree/master/packages/jest-types/src/Circus.ts)). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases.
991991

992-
Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with it's value set to an empty string. If the pragma is not present, it will not be present in the object.
992+
Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object.
993993

994994
_Note: TestEnvironment is sandboxed. Each test suite will trigger setup/teardown in their own TestEnvironment._
995995

docs/ExpectAPI.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ For additional Jest matchers maintained by the Jest Community check out [`jest-e
1717

1818
### `expect(value)`
1919

20-
The `expect` function is used every time you want to test a value. You will rarely call `expect` by itself. Instead, you will use `expect` along with a "matcher" function to assert something about value.
20+
The `expect` function is used every time you want to test a value. You will rarely call `expect` by itself. Instead, you will use `expect` along with a "matcher" function to assert something about a value.
2121

2222
It's easier to understand this with an example. Let's say you have a method `bestLaCroixFlavor()` which is supposed to return the string `'grapefruit'`. Here's how you would test that:
2323

docs/GettingStarted.md

+4-13
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jest --init
8181

8282
### Using Babel
8383

84-
To use [Babel](http://babeljs.io/), install required dependencies via `yarn`:
84+
To use [Babel](https://babeljs.io/), install required dependencies via `yarn`:
8585

8686
```bash
8787
yarn add --dev babel-jest @babel/core @babel/preset-env
@@ -92,20 +92,11 @@ Configure Babel to target your current version of Node by creating a `babel.conf
9292
```javascript
9393
// babel.config.js
9494
module.exports = {
95-
presets: [
96-
[
97-
'@babel/preset-env',
98-
{
99-
targets: {
100-
node: 'current',
101-
},
102-
},
103-
],
104-
],
95+
presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
10596
};
10697
```
10798

108-
**The ideal configuration for Babel will depend on your project.** See [Babel's docs](https://babeljs.io/docs/en/) for more details.
99+
_The ideal configuration for Babel will depend on your project._ See [Babel's docs](https://babeljs.io/docs/en/) for more details.
109100

110101
<details><summary markdown="span"><strong>Making your Babel config jest-aware</strong></summary>
111102

@@ -179,4 +170,4 @@ module.exports = {
179170
};
180171
```
181172

182-
However, there are some [caveats](https://babeljs.io/docs/en/next/babel-plugin-transform-typescript.html#caveats) to using TypeScript with Babel. Because TypeScript support in Babel is transpilation, Jest will not type-check your tests as they are run. If you want that, you can use [ts-jest](https://github.com/kulshekhar/ts-jest).
173+
However, there are some [caveats](https://babeljs.io/docs/en/babel-plugin-transform-typescript#caveats) to using TypeScript with Babel. Because TypeScript support in Babel is transpilation, Jest will not type-check your tests as they are run. If you want that, you can use [ts-jest](https://github.com/kulshekhar/ts-jest).

docs/SnapshotTesting.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ exports[`renders correctly 1`] = `
3939
`;
4040
```
4141

42-
The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/facebook/jest/tree/master/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in this case, it's `<Link>` component) that should be fixed, or the implementation has changed and the snapshot needs to be updated.
42+
The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process. Jest uses [pretty-format](https://github.com/facebook/jest/tree/master/packages/pretty-format) to make snapshots human-readable during code review. On subsequent test runs, Jest will compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the `<Link>` component in this case) that should be fixed, or the implementation has changed and the snapshot needs to be updated.
4343

44-
> Note: The snapshot is directly scoped to the data you render – in our example it's `<Link />` component with page prop passed to it. This implies that even if any other file has missing props (Say, `App.js`) in the `<Link />` component, it will still pass the test as the test doesn't know the usage of `<Link />` component and it's scoped only to the `Link.react.js`. Also, Rendering the same component with different props in other snapshot tests will not affect the first one, as the tests don't know about each other.
44+
> Note: The snapshot is directly scoped to the data you render – in our example the `<Link />` component with `page` prop passed to it. This implies that even if any other file has missing props (Say, `App.js`) in the `<Link />` component, it will still pass the test as the test doesn't know the usage of `<Link />` component and it's scoped only to the `Link.react.js`. Also, Rendering the same component with different props in other snapshot tests will not affect the first one, as the tests don't know about each other.
4545
4646
More information on how snapshot testing works and why we built it can be found on the [release blog post](https://jestjs.io/blog/2016/07/27/jest-14.html). We recommend reading [this blog post](http://benmccormick.org/2016/09/19/testing-with-jest-snapshots-first-impressions/) to get a good sense of when you should use snapshot testing. We also recommend watching this [egghead video](https://egghead.io/lessons/javascript-use-jest-s-snapshot-testing-feature?pl=testing-javascript-with-jest-a36c4074) on Snapshot Testing with Jest.
4747

website/versioned_docs/version-24.x/Architecture.md website/versioned_docs/version-22.x/Architecture.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
id: version-24.x-architecture
2+
id: version-22.x-architecture
33
title: Architecture
44
original_id: architecture
55
---

website/versioned_docs/version-23.x/BypassingModuleMocks.md website/versioned_docs/version-22.x/BypassingModuleMocks.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
id: version-23.x-bypassing-module-mocks
2+
id: version-22.x-bypassing-module-mocks
33
title: Bypassing module mocks
44
original_id: bypassing-module-mocks
55
---

website/versioned_docs/version-22.x/CLI.md

+17-5
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ Forces test results output highlighting even if stdout is not a TTY.
134134

135135
Alias: `-c`. The path to a Jest config file specifying how to find and execute tests. If no `rootDir` is set in the config, the directory containing the config file is assumed to be the `rootDir` for the project. This can also be a JSON-encoded value which Jest will use as configuration.
136136

137-
### `--coverage`
137+
### `--coverage[=<boolean>]`
138138

139-
Indicates that test coverage information should be collected and reported in the output.
139+
Alias: `--collectCoverage`. Indicates that test coverage information should be collected and reported in the output. Optionally pass `<boolean>` to override option set in configuration.
140140

141141
### `--debug`
142142

@@ -202,9 +202,15 @@ Alias: `-o`. Attempts to identify which tests to run based on which files have c
202202

203203
Allows the test suite to pass when no files are found.
204204

205-
### `--projects <project1> ... <projectN>`
205+
### `--projects <path1> ... <pathN>`
206206

207-
Run tests from one or more projects.
207+
Run tests from one or more projects, found in the specified paths; also takes path globs. This option is the CLI equivalent of the [`projects`](configuration#projects-arraystring--projectconfig) configuration option. Note that if configuration files are found in the specified paths, _all_ projects specified within those configuration files will be run.
208+
209+
### `--reporters`
210+
211+
Run tests with specified reporters. Run tests with specified reporters. Example with multiple reporters:
212+
213+
`jest --reporters="default" --reporters="jest-junit"`
208214

209215
### `--runInBand`
210216

@@ -230,7 +236,9 @@ Prevent tests from printing messages through the console.
230236

231237
### `--testNamePattern=<regex>`
232238

233-
Alias: `-t`. Run only tests and test suites with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like `"GET /api/posts with auth"`, then you can use `jest -t=auth`.
239+
Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like `"GET /api/posts with auth"`, then you can use `jest -t=auth`.
240+
241+
_Note: The regex is matched against the full name, which is a combination of the test name and all its surrounding describe blocks._
234242

235243
### `--testLocationInResults`
236244

@@ -249,6 +257,10 @@ Note that `column` is 0-indexed while `line` is not.
249257

250258
A regexp pattern string that is matched against all tests paths before executing the test. On Windows, you will need to use `/` as a path separator or escape `\` as `\\`.
251259

260+
### `--testPathIgnorePatterns=[array]`
261+
262+
An array of regexp pattern strings that are tested against all tests paths before executing the test. Contrary to `--testPathPattern`, it will only run those tests with a path that does not match with the provided regexp expressions.
263+
252264
### `--testRunner=<path>`
253265

254266
Lets you specify a custom test runner.

0 commit comments

Comments
 (0)