From c88a8b6b9ed8fa30fd61ae6c67ffb53f15284f31 Mon Sep 17 00:00:00 2001 From: rickhanlonii Date: Tue, 20 Feb 2018 12:51:24 -0500 Subject: [PATCH 1/2] Update to docs --- CHANGELOG.md | 3 ++- README.md | 14 +++++----- docs/CLI.md | 27 ++++++++++++++++--- docs/GettingStarted.md | 16 +++++------ docs/MigrationGuide.md | 4 +-- docs/Troubleshooting.md | 10 +++---- docs/TutorialReact.md | 9 +++---- docs/TutorialReactNative.md | 4 +-- docs/UsingMatchers.md | 6 ++--- docs/Webpack.md | 2 +- packages/babel-jest/README.md | 4 +-- packages/babel-plugin-jest-hoist/README.md | 2 +- website/README.md | 6 ++--- website/blog/2016-07-27-jest-14.md | 6 ++--- website/blog/2016-12-15-2016-in-jest.md | 10 +++---- ...e-watch-mode-test-platform-improvements.md | 2 +- 16 files changed, 72 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa4f871452f9..ab74648c4a75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ * `[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)) ## 22.4.0 diff --git a/README.md b/README.md index b980c7f7c338..9adc571f9374 100644 --- a/README.md +++ b/README.md @@ -21,16 +21,16 @@ -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 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 @@ -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 @@ -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: @@ -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 diff --git a/docs/CLI.md b/docs/CLI.md index ec1095211e21..ad98e977b092 100644 --- a/docs/CLI.md +++ b/docs/CLI.md @@ -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" @@ -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)._ + --- diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index 132c04abbec6..a989ab243511 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -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 @@ -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 @@ -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: @@ -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 diff --git a/docs/MigrationGuide.md b/docs/MigrationGuide.md index a06df16ea902..79d7eb29041a 100644 --- a/docs/MigrationGuide.md +++ b/docs/MigrationGuide.md @@ -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 diff --git a/docs/Troubleshooting.md b/docs/Troubleshooting.md index 037115dfe31f..e2de98603998 100644 --- a/docs/Troubleshooting.md +++ b/docs/Troubleshooting.md @@ -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 @@ -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 @@ -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. diff --git a/docs/TutorialReact.md b/docs/TutorialReact.md index aa9c2b3751bd..8a4392e65502 100644 --- a/docs/TutorialReact.md +++ b/docs/TutorialReact.md @@ -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 `` @@ -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 @@ -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: diff --git a/docs/TutorialReactNative.md b/docs/TutorialReactNative.md index e4924fb071a6..6a1374ed4693 100644 --- a/docs/TutorialReactNative.md +++ b/docs/TutorialReactNative.md @@ -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 @@ -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 diff --git a/docs/UsingMatchers.md b/docs/UsingMatchers.md index a7dafbbf4e01..be5999457601 100644 --- a/docs/UsingMatchers.md +++ b/docs/UsingMatchers.md @@ -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 diff --git a/docs/Webpack.md b/docs/Webpack.md index d564b7c0a02e..ade707c8964e 100644 --- a/docs/Webpack.md +++ b/docs/Webpack.md @@ -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 diff --git a/packages/babel-jest/README.md b/packages/babel-jest/README.md index 304dd95333f2..2eeec0ed3382 100644 --- a/packages/babel-jest/README.md +++ b/packages/babel-jest/README.md @@ -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 diff --git a/packages/babel-plugin-jest-hoist/README.md b/packages/babel-plugin-jest-hoist/README.md index 5adf69f92e66..7cfd9f4a0e09 100644 --- a/packages/babel-plugin-jest-hoist/README.md +++ b/packages/babel-plugin-jest-hoist/README.md @@ -8,7 +8,7 @@ automatically included when using ## Installation ```sh -$ npm install babel-plugin-jest-hoist +$ yarn add --dev babel-plugin-jest-hoist ``` ## Usage diff --git a/website/README.md b/website/README.md index fbbcfaeae3db..4d097a551bad 100644 --- a/website/README.md +++ b/website/README.md @@ -13,7 +13,7 @@ in the root directory. Then, run the server via ```bash -npm start +yarn start Open http://localhost:3000 ``` @@ -30,7 +30,7 @@ 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 @@ -38,5 +38,5 @@ DEPLOY_USER=facebook GIT_USER=jest-bot CIRCLE_PROJECT_USERNAME=facebook CIRCLE_P 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 ``` diff --git a/website/blog/2016-07-27-jest-14.md b/website/blog/2016-07-27-jest-14.md index 6a1af7a984ef..12e48475092d 100644 --- a/website/blog/2016-07-27-jest-14.md +++ b/website/blog/2016-07-27-jest-14.md @@ -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 @@ -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: diff --git a/website/blog/2016-12-15-2016-in-jest.md b/website/blog/2016-12-15-2016-in-jest.md index 5775571ec007..f4d4a1bed48d 100644 --- a/website/blog/2016-12-15-2016-in-jest.md +++ b/website/blog/2016-12-15-2016-in-jest.md @@ -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 @@ -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). diff --git a/website/blog/2017-02-21-jest-19-immersive-watch-mode-test-platform-improvements.md b/website/blog/2017-02-21-jest-19-immersive-watch-mode-test-platform-improvements.md index 77e3975cb6d2..916375b20c94 100644 --- a/website/blog/2017-02-21-jest-19-immersive-watch-mode-test-platform-improvements.md +++ b/website/blog/2017-02-21-jest-19-immersive-watch-mode-test-platform-improvements.md @@ -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 `yarn add --dev eslint eslint-plugin-jest` and it can be enabled by adding `{"plugins": ["jest"]}` to your eslint configuration. From caa677f83e47eac12b160e4c4446f52489d2dd42 Mon Sep 17 00:00:00 2001 From: rickhanlonii Date: Tue, 20 Feb 2018 12:54:25 -0500 Subject: [PATCH 2/2] Add changelog --- CHANGELOG.md | 2 ++ docs/TutorialReact.md | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab74648c4a75..b5e44b199c6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ([#5618](https://github.com/facebook/jest/pull/5618)) * `[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 diff --git a/docs/TutorialReact.md b/docs/TutorialReact.md index 8a4392e65502..b761ce5a8743 100644 --- a/docs/TutorialReact.md +++ b/docs/TutorialReact.md @@ -226,8 +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 `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`. +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: