Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to docs to use yarn #5624

Merged
merged 2 commits into from
Feb 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

* `[jest-runtime]` Provide `require.main` property set to module with test suite
([#5618](https://github.com/facebook/jest/pull/5618))
* `[docs]` Add note about Node version support ([#5622](https://github.com/facebook/jest/pull/5622))
* `[docs]` Add note about Node version support
([#5622](https://github.com/facebook/jest/pull/5622))
* `[docs]` Update to use yarn
([#5624](https://github.com/facebook/jest/pull/5624))

## 22.4.0

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@

<!-- generated_getting_started_start -->

Install Jest using [`npm`](https://www.npmjs.com/):
Install Jest using [`yarn`](https://yarnpkg.com/en/package/jest):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept yarn and npm here but switched the order


```bash
npm install --save-dev jest
yarn add --dev jest
```

Or via [`yarn`](https://yarnpkg.com/en/package/jest):
Or via [`npm`](https://www.npmjs.com/):

```bash
yarn add --dev jest
npm install --save-dev jest
```

The minimum supported Node version is `v6.0.0` by default. If you need to
Expand Down Expand Up @@ -68,7 +68,7 @@ Add the following section to your `package.json`:
}
```

Finally, run `npm test` and Jest will print this message:
Finally, run `yarn test` and Jest will print this message:

```bash
PASS ./sum.test.js
Expand All @@ -84,7 +84,7 @@ identical. To learn about the other things that Jest can test, see
## Running from command line

You can run Jest directly from the CLI (if it's globally available in your
`PATH`, e.g. by `npm install -g jest`) with variety of useful options.
`PATH`, e.g. by `yarn global add jest`) with variety of useful options.

Here's how to run Jest on files matching `my-test`, using `config.json` as a
configuration file and display a native OS notification after the run:
Expand All @@ -108,7 +108,7 @@ You don't need install anything extra for using Babel.
> `babel-core@^7.0.0-0` and `@babel/core` with the following command:
>
> ```bash
> npm install --save-dev 'babel-core@^7.0.0-0' @babel/core
> yarn add --dev 'babel-core@^7.0.0-0' @babel/core
> ```

Don't forget to add a [`.babelrc`](https://babeljs.io/docs/usage/babelrc/) file
Expand Down
27 changes: 23 additions & 4 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,29 @@ jest --watchAll #runs all tests
Watch mode also enables to specify the name or path to a file to focus on a
specific set of tests.

## Using with yarn

If you run Jest via `yarn test`, you can pass the command line arguments
directly as Jest arguments.

Instead of:

```bash
jest -u -t="ColorPicker"
```

you can use:

```bash
yarn test -u -t="ColorPicker"
```

## Using with npm scripts

If you run Jest via `npm test`, you can still use the command line arguments by
inserting a `--` between `npm test` and the Jest arguments. Instead of:
inserting a `--` between `npm test` and the Jest arguments.

Instead of:

```bash
jest -u -t="ColorPicker"
Expand All @@ -69,11 +88,11 @@ you can use:
npm test -- -u -t="ColorPicker"
```

CLI options take precedence over values from the
[Configuration](Configuration.md).

## Options

_Note: CLI options take precedence over values from the
[Configuration](Configuration.md)._

<AUTOGENERATED_TABLE_OF_CONTENTS>

---
Expand Down
16 changes: 8 additions & 8 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ id: getting-started
title: Getting Started
---

Install Jest using [`npm`](https://www.npmjs.com/):
Install Jest using [`yarn`](https://yarnpkg.com/en/package/jest):

```bash
npm install --save-dev jest
yarn add --dev jest
```

Or via [`yarn`](https://yarnpkg.com/en/package/jest):
Or [`npm`](https://www.npmjs.com/):

```bash
yarn add --dev jest
npm install --save-dev jest
```

Let's get started by writing a test for a hypothetical function that adds two
Expand Down Expand Up @@ -45,7 +45,7 @@ Add the following section to your `package.json`:
}
```

Finally, run `npm test` and Jest will print this message:
Finally, run `yarn test` and Jest will print this message:

```bash
PASS ./sum.test.js
Expand All @@ -61,7 +61,7 @@ identical. To learn about the other things that Jest can test, see
## Running from command line

You can run Jest directly from the CLI (if it's globally available in your
`PATH`, e.g. by `npm install -g jest`) with variety of useful options.
`PATH`, e.g. by `yarn global add jest`) with variety of useful options.

Here's how to run Jest on files matching `my-test`, using `config.json` as a
configuration file and display a native OS notification after the run:
Expand All @@ -81,14 +81,14 @@ To use [Babel](http://babeljs.io/), install the `babel-jest` and
`regenerator-runtime` packages:

```bash
npm install --save-dev babel-jest babel-core regenerator-runtime
yarn add --dev babel-jest babel-core regenerator-runtime
```

> Note: If you are using a babel version 7 then you need to install `babel-jest`
> with the following command:
>
> ```bash
> npm install --save-dev babel-jest 'babel-core@^7.0.0-0' @babel/core regenerator-runtime
> yarn add --dev babel-jest 'babel-core@^7.0.0-0' @babel/core regenerator-runtime
> ```

_Note: Explicitly installing `regenerator-runtime` is not needed if you use
Expand Down
4 changes: 2 additions & 2 deletions docs/MigrationGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ If you are using [AVA](https://github.com/avajs/ava),
dirty migration work. It runs a code transformation on your codebase using
[jscodeshift](https://github.com/facebook/jscodeshift).

Install Jest Codemods with `npm` by running:
Install Jest Codemods with `yarn` by running:

```bash
npm install -g jest-codemods
yarn global add jest-codemods
```

To transform your existing tests, navigate to the project containing the tests
Expand Down
10 changes: 5 additions & 5 deletions docs/Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ In order to do this you can run tests in the same thread using
# Using Jest CLI
jest --runInBand

# Using npm test (e.g. with create-react-app)
npm test -- --runInBand
# Using yarn test (e.g. with create-react-app)
yarn test --runInBand
```

Another alternative to expediting test execution time on Continuous Integration
Expand All @@ -229,8 +229,8 @@ _free_ plan available for open source projects only includes 2 CPU cores.
# Using Jest CLI
jest --maxWorkers=4

# Using npm test (e.g. with create-react-app)
npm test -- --maxWorkers=4
# Using yarn test (e.g. with create-react-app)
yarn test --maxWorkers=4
```

### Tests are slow when leveraging automocking
Expand Down Expand Up @@ -306,7 +306,7 @@ version used in Jest doesn't support Node 4. However, if you need to run Jest on
Node 4, you can use the `testEnvironment` config to use a
[custom environment](https://facebook.github.io/jest/docs/en/configuration.html#testenvironment-string)
that supports Node 4, such as
[`jest-environment-node`](https://www.npmjs.com/package/jest-environment-node).
[`jest-environment-node`](https://yarnpkg.com/en/package/jest-environment-node).

### `coveragePathIgnorePatterns` seems to not have any effect.

Expand Down
9 changes: 4 additions & 5 deletions docs/TutorialReact.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Also see [using babel](GettingStarted.md#using-babel).
Run

```bash
npm install --save-dev jest babel-jest babel-preset-env babel-preset-react react-test-renderer
yarn add --dev jest babel-jest babel-preset-env babel-preset-react react-test-renderer
```

Your `package.json` should look something like this (where `<current-version>`
Expand Down Expand Up @@ -140,7 +140,7 @@ test('Link changes the class when hovered', () => {
});
```

When you run `npm test` or `jest`, this will produce an output file like this:
When you run `yarn test` or `jest`, this will produce an output file like this:

```javascript
// __tests__/__snapshots__/Link.react.test.js.snap
Expand Down Expand Up @@ -226,9 +226,8 @@ If you'd like to assert, and manipulate your rendered components you can use
[TestUtils](http://facebook.github.io/react/docs/test-utils.html). We use Enzyme
for this example.

You have to run `npm install --save-dev enzyme` to use Enzyme. If you are using
a React below version 15.5.0, you will also need to install
`react-addons-test-utils`.
You have to run `yarn add --dev enzyme` to use Enzyme. If you are using a React
version below 15.5.0, you will also need to install `react-addons-test-utils`.

Let's implement a simple checkbox which swaps between two labels:

Expand Down
4 changes: 2 additions & 2 deletions docs/TutorialReactNative.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ _Note: If you are upgrading your react-native application and previously used
the `jest-react-native` preset, remove the dependency from your `package.json`
file and change the preset to `react-native` instead._

Simply run `npm test` to run tests with Jest.
Simply run `yarn test` to run tests with Jest.

## Snapshot Test

Expand Down Expand Up @@ -93,7 +93,7 @@ test('renders correctly', () => {
});
```

When you run `npm test` or `jest`, this will produce an output file like this:
When you run `yarn test` or `jest`, this will produce an output file like this:

```javascript
// __tests__/__snapshots__/Intro-test.js.snap
Expand Down
6 changes: 3 additions & 3 deletions docs/UsingMatchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ id: using-matchers
title: Using Matchers
---

Jest uses "matchers" to let you test values in different ways. This document
will introduce some commonly used matchers. For the full list,
see the [`expect` API doc](ExpectAPI.md).
Jest uses "matchers" to let you test values in different ways. This document
will introduce some commonly used matchers. For the full list, see the
[`expect` API doc](ExpectAPI.md).

### Common Matchers

Expand Down
2 changes: 1 addition & 1 deletion docs/Webpack.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ You can use an [ES6 Proxy](https://github.com/keyanzhang/identity-obj-proxy) to
mock [CSS Modules](https://github.com/css-modules/css-modules):

```bash
npm install --save-dev identity-obj-proxy
yarn add --dev identity-obj-proxy
```

Then all your className lookups on the styles object will be returned as-is
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-jest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ If you are already using `jest-cli`, just add `babel-jest` and it will
automatically compile JavaScript code using babel.

```bash
npm install --save-dev babel-jest babel-core
yarn add --dev babel-jest babel-core
```

> Note: If you are using babel version 7 you have to install `babel-jest` with
>
> ```bash
> npm install --save-dev babel-jest babel-core@^7.0.0-0 @babel/core
> yarn add --dev babel-jest babel-core@^7.0.0-0 @babel/core
> ```

If you would like to write your own preprocessor, uninstall and delete
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-jest-hoist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ automatically included when using
## Installation

```sh
$ npm install babel-plugin-jest-hoist
$ yarn add --dev babel-plugin-jest-hoist
```

## Usage
Expand Down
6 changes: 3 additions & 3 deletions website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ in the root directory.
Then, run the server via

```bash
npm start
yarn start
Open http://localhost:3000
```

Expand All @@ -30,13 +30,13 @@ To deploy the website manually, run the following command as a Git user with
write permissions:

```bash
DEPLOY_USER=facebook GIT_USER=jest-bot CIRCLE_PROJECT_USERNAME=facebook CIRCLE_PROJECT_REPONAME=jest npm run gh-pages
DEPLOY_USER=facebook GIT_USER=jest-bot CIRCLE_PROJECT_USERNAME=facebook CIRCLE_PROJECT_REPONAME=jest yarn gh-pages
```

## Staging

Run the above command against your own fork of `facebook/jest`:

```bash
DEPLOY_USER=YOUR_GITHUB_USERNAME GIT_USER=YOUR_GITHUB_USERNAME CIRCLE_PROJECT_USERNAME=YOUR_GITHUB_USERNAME CIRCLE_PROJECT_REPONAME=jest npm run gh-pages
DEPLOY_USER=YOUR_GITHUB_USERNAME GIT_USER=YOUR_GITHUB_USERNAME CIRCLE_PROJECT_USERNAME=YOUR_GITHUB_USERNAME CIRCLE_PROJECT_REPONAME=jest yarn gh-pages
```
6 changes: 3 additions & 3 deletions website/blog/2016-07-27-jest-14.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ launch experimental React Native support for Jest through the
`jest-react-native` package.

You can start using Jest with react-native by running
`npm install --save-dev jest-react-native` and by adding the preset to your Jest
`yarn add --dev jest-react-native` and by adding the preset to your Jest
configuration:

```json
Expand Down Expand Up @@ -149,8 +149,8 @@ changed his unit testing experience:

## What's next for Jest

Recently [Aaron Abramov](https://twitter.com/aaronabramov_) has joined the
Jest team full time to improve our unit and integration test infrastructure for
Recently [Aaron Abramov](https://twitter.com/aaronabramov_) has joined the Jest
team full time to improve our unit and integration test infrastructure for
Facebook's ads products. For the next few months the Jest team is planning major
improvements in these areas:

Expand Down
10 changes: 5 additions & 5 deletions website/blog/2016-12-15-2016-in-jest.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ and adopted [lerna](https://lernajs.io/) to turn Jest from a framework into a
[_Painless JavaScript Testing platform_](https://github.com/facebook/jest/tree/master/packages).

The newly created
[react-test-renderer](https://www.npmjs.com/package/react-test-renderer) finally
enabled testing of react-native components. Through the jest-react-native preset
(now merged directly into react-native) Jest now works out of the box for any
React project and comes pre-configured in
[react-test-renderer](https://yarnpkg.com/en/package/react-test-renderer)
finally enabled testing of react-native components. Through the
jest-react-native preset (now merged directly into react-native) Jest now works
out of the box for any React project and comes pre-configured in
[create-react-app](https://github.com/facebookincubator/create-react-app) and
[react-native](https://github.com/facebook/react-native) projects. We integrated
core pieces of Jest into
Expand Down Expand Up @@ -121,7 +121,7 @@ Here is what happened in the community in the last two months:
happening right now.
* Dmitrii made a new
[music video with his metal band](https://twitter.com/abramov_dmitrii/status/806613542447157248).
* [lazyspec](https://www.npmjs.com/package/lazyspec) can help you create smoke
* [lazyspec](https://yarnpkg.com/en/package/lazyspec) can help you create smoke
tests quickly if you are introducing tests to an existing codebase.
* Patrick Stapfer did a lightning talk about
[vim and Jest](https://twitter.com/ryyppy/status/803871975995277312).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ official ESLint plugin. It exposes three rules:
* [no-identical-title](https://github.com/facebook/jest/blob/master/packages/eslint-plugin-jest/docs/rules/no-identical-title.md) -
disallows identical titles in test names.

You can install it using `npm install eslint-plugin-jest` or
You can install it using `npm install --save-dev eslint-plugin-jest` or
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added for parity with the yarn command

`yarn add --dev eslint eslint-plugin-jest` and it can be enabled by adding
`{"plugins": ["jest"]}` to your eslint configuration.

Expand Down