Skip to content

Commit

Permalink
[πŸ”₯] Revised README (#8076)
Browse files Browse the repository at this point in the history
πŸ‘‹  been having a think about READMEs lately, and wanted to try give the README a fresh perspective and kinda bring it inline with the jestsj.io update.

- Current: [README](https://github.com/facebook/jest/blob/690221b5db85e024e2738d30ed2633275d4c63ab/README.md)
- New: [README](https://github.com/orta/jest/blob/new_readme/README.md)

Major focuses:

- Removal of most badges. This isn't a hill I'll die on, but TBH, most of them provide little value to someone looking at using Jest. 
  - Knowing the CI is green for a small project is _reasonably_ useful, barely. Knowing CI is green three times on a large project isn't. We're very unlikely to leave jest as red CI for very long, given the domain Jest is in.
  - Knowing the current version of Jest on NPM is pretty useful, especially as the major is so high, so I kept that
  - I think the open collective numbers are _kinda_ useful, (as a user, knowing that there's potential long-term stability) but there's a lot of space given to them at the bottom of the readme
  - I did think the 'breaks semver' one was clever, so am open to that coming back somehow, but still not sure that's something someone would really care about

- Moved some more advanced-y, or edge-cases-y docs into `<details>`
  - We should note babel 6 support, but it doesn't need to take up space
  - We've never checked for Jest inside babel at Artsy, so I think it's probably an edge case, so I moved that into a summary also

- Gave the TypeScript docs a one-over. I improved the copy in the docs, and inlined the examples of how to get started, given that it's not much extra. I switched the reference link from our Artsy post, to the official babel docs (and improved them again babel/website#1982 ) - mainly because our post reflected the alpha+beta stuff, and some of that isn't valid anymore, better to have it focus on the canonical docs here.

Also managed to get some of the descriptions down to a single line of text in the README, which is always a win in my book. This also de-Reacts it a little bit too.
  • Loading branch information
orta authored and cpojer committed Mar 18, 2019
1 parent 30cb244 commit 4ba05b7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 60 deletions.
94 changes: 38 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,19 @@
<h1 align="center">
<img src="https://jestjs.io/img/jest.png" height="150" width="150"/>
<p align="center">Jest</p>
<p align="center" style="font-size: 0.5em">πŸƒ Delightful JavaScript Testing</p>
</h1>

<p align="center">
<a href="https://circleci.com/gh/facebook/jest"><img src="https://circleci.com/gh/facebook/jest.svg?style=shield" alt="CircleCI Build Status"></a>
<a href="https://dev.azure.com/jestjs/jest/_build/latest?definitionId=1?branchName=master"><img src="https://dev.azure.com/jestjs/jest/_apis/build/status/facebook.jest?branchName=master" alt="Azure Pipelines Build Status"></a>
<a href="https://travis-ci.org/facebook/jest"><img src="https://travis-ci.org/facebook/jest.svg?branch=master" alt="Travis Build Status"></a>
<a href="https://ci.appveyor.com/project/Daniel15/jest/branch/master"><img src="https://ci.appveyor.com/api/projects/status/8n38o44k585hhvhd/branch/master?svg=true" alt="Windows Build Status"></a>
<a href="https://codecov.io/gh/facebook/jest"><img src="https://codecov.io/gh/facebook/jest/branch/master/graph/badge.svg" alt="Codecov badge"></a>
<a href="http://badge.fury.io/js/jest"><img src="https://badge.fury.io/js/jest.svg" alt="npm version"></a>
<a href="https://dependabot.com/compatibility-score.html?dependency-name=jest&amp;package-manager=npm_and_yarn&amp;version-scheme=semver"><img src="https://api.dependabot.com/badges/compatibility_score?dependency-name=jest&amp;package-manager=npm_and_yarn&amp;version-scheme=semver" alt="SemVer">
<a href="https://twitter.com/acdlite/status/974390255393505280"><img src="https://img.shields.io/badge/speed-blazing%20%F0%9F%94%A5-brightgreen.svg" alt="Blazing Fast"></a>
</p>
<p align="center">
<a href="#backers"><img src="https://opencollective.com/jest/backers/badge.svg" alt="Backers on Open Collective"></a>
<a href="#sponsors"><img src="https://opencollective.com/jest/sponsors/badge.svg" alt="Sponsors on Open Collective"></a>
<a href="https://github.com/facebook/jest/blob/master/CONTRIBUTING.md"><img src="https://img.shields.io/badge/PRs%20-welcome-brightgreen.svg" alt="PR's welcome"></a>
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
<a href="https://snyk.io/test/github/facebook/jest?targetFile=packages/jest/package.json"><img src="https://snyk.io/test/github/facebook/jest/badge.svg?targetFile=packages/jest/package.json" alt="Known Vulnerabilities" data-canonical-src="https://snyk.io/test/github/facebook/jest?targetFile=packages/jest/package.json" style="max-width:100%;"></a>
</p>
<p align="center">
<a href="https://twitter.com/intent/follow?screen_name=fbjest"><img src="https://img.shields.io/twitter/follow/fbjest.svg?style=social&label=Follow%20@fbjest" alt="Follow on Twitter"></a>
<p>
<a href="http://badge.fury.io/js/jest"><img src="https://badge.fury.io/js/jest.svg" alt="npm version"></a>
<a href="https://twitter.com/intent/follow?screen_name=fbjest"><img align="right" src="https://img.shields.io/twitter/follow/fbjest.svg?style=social&label=Follow%20@fbjest" alt="Follow on Twitter"></a>
</p>

**πŸ‘©πŸ»β€πŸ’» Developer Ready**: Complete and ready to set-up JavaScript testing solution. Works out of the box for any React project.
<p align="center"><img src="website/static/img/jest-readme-headline.png" height="289" width="700"/></p>

<h1 align="center">πŸƒ Delightful JavaScript Testing</h1>

**πŸƒπŸ½ Instant Feedback**: Fast interactive watch mode runs only test files related to changed files and is optimized to give signal quickly.
**πŸ‘©πŸ»β€πŸ’» Developer Ready**: A comprehensive JavaScript testing solution. Works out of the box for most JavaScript projects.

**πŸ“Έ Snapshot Testing**: Capture snapshots of React trees or other serializable values to simplify testing and to analyze how state changes over time.
**πŸƒπŸ½ Instant Feedback**: Fast, interactive watch mode only runs test files related to changed files.

**πŸ“Έ Snapshot Testing**: Capture snapshots of large objects to simplify testing and to analyze how they change over time.

<p align="right"><em>See more on <a href="https://jestjs.io">jestjs.io</a></em></p>

## Getting Started

Expand Down Expand Up @@ -119,25 +103,18 @@ To use [Babel](http://babeljs.io/), install required dependencies via `yarn`:
yarn add --dev babel-jest @babel/core @babel/preset-env
```

Configure Babel to target your current version of Node by creating a `babel.config.js` file in the root of your project:
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:

```javascript
// babel.config.js
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
};
```

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

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

Jest will set `process.env.NODE_ENV` to `'test'` if it's not set to something else. You can use that in your configuration to conditionally setup only the compilation needed for Jest, e.g.

Expand All @@ -162,30 +139,35 @@ module.exports = {
};
```

#### Babel 6

Jest 24 dropped support for Babel 6. We highly recommend you to upgrade to Babel 7, which is actively maintained. However, if you cannot upgrade to Babel 7, either keep using Jest 23 or upgrade to Jest 24 with `babel-jest` locked at version 23, like in the example below:

```
"dependencies": {
"babel-core": "^6.26.3",
"babel-jest": "^23.6.0",
"babel-preset-env": "^1.7.0",
"jest": "^24.0.0"
}
```
</details>

While we generally recommend using the same version of every Jest package, this workaround will allow you to continue using the latest version of Jest with Babel 6 for now.
<!-- Note that the Babel 6 section in the Getting Started was removed -->

### Using webpack

Jest can be used in projects that use [webpack](https://webpack.github.io/) to manage assets, styles, and compilation. webpack does offer some unique challenges over other tools. Refer to the [webpack guide](https://jestjs.io/docs/en/webpack) to get started.

### Using TypeScript

Jest supports TypeScript out of the box, via Babel.
Jest supports TypeScript, via Babel. First make sure you followed the instructions on [using Babel](#using-babel) above. Next install the `@babel/preset-typescript` via `yarn`:

```bash
yarn add --dev @babel/preset-typescript
```

Then add `@babel/preset-typescript` to the list of presets in your `babel.config.js`.

```diff
// babel.config.js
module.exports = {
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
+ '@babel/preset-typescript',
],
};
```

However, there are some caveats to using Typescript with Babel, see http://artsy.github.io/blog/2017/11/27/Babel-7-and-TypeScript/. Another caveat is that Jest will not typecheck your tests. If you want that, you can use [ts-jest](https://github.com/kulshekhar/ts-jest).
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 just transpilation, Jest will not type-check your tests as they are ran. If you want that, you can use [ts-jest](https://github.com/kulshekhar/ts-jest).

<!-- end copied -->

Expand All @@ -200,7 +182,7 @@ Learn more about using [Jest on the official site!](https://jestjs.io)

## Badge

Show the world you're using _Jest_ β†’ [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest) [![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/facebook/jest)
Show the world you're using _Jest_ `β†’` [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest) [![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/facebook/jest)

```md
[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest) [![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/facebook/jest)
Expand Down
14 changes: 10 additions & 4 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ module.exports = {

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

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

Jest will set `process.env.NODE_ENV` to `'test'` if it's not set to something else. You can use that in your configuration to conditionally setup only the compilation needed for Jest, e.g.

```javascript
Expand All @@ -130,7 +132,9 @@ module.exports = {
};
```

#### Babel 6
</details>

<details><summary markdown="span"><strong>Babel 6 support</strong></summary>

Jest 24 dropped support for Babel 6. We highly recommend you to upgrade to Babel 7, which is actively maintained. However, if you cannot upgrade to Babel 7, either keep using Jest 23 or upgrade to Jest 24 with `babel-jest` locked at version 23, like in the example below:

Expand All @@ -145,6 +149,8 @@ Jest 24 dropped support for Babel 6. We highly recommend you to upgrade to Babel

While we generally recommend using the same version of every Jest package, this workaround will allow you to continue using the latest version of Jest with Babel 6 for now.

</details>

### Using webpack

Jest can be used in projects that use [webpack](https://webpack.github.io/) to manage assets, styles, and compilation. webpack does offer some unique challenges over other tools. Refer to the [webpack guide](Webpack.md) to get started.
Expand All @@ -159,14 +165,14 @@ yarn add --dev @babel/preset-typescript

Then add `@babel/preset-typescript` to the list of presets in your `babel.config.js`.

```javascript
```diff
// babel.config.js
module.exports = {
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
'@babel/preset-typescript',
+ '@babel/preset-typescript',
],
};
```

Note that there are some caveats to using Typescript with Babel, see http://artsy.github.io/blog/2017/11/27/Babel-7-and-TypeScript/. Another caveat is that Jest will not typecheck your tests. If you want that, you can use [ts-jest](https://github.com/kulshekhar/ts-jest).
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 just transpilation, Jest will not type-check your tests as they are ran. If you want that, you can use [ts-jest](https://github.com/kulshekhar/ts-jest).
Binary file added website/static/img/jest-readme-headline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4ba05b7

Please sign in to comment.