You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
π 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.
<ahref="https://twitter.com/intent/follow?screen_name=fbjest"><imgalign="right"src="https://img.shields.io/twitter/follow/fbjest.svg?style=social&label=Follow%20@fbjest"alt="Follow on Twitter"></a>
**πΈ Snapshot Testing**: Capture snapshots of React trees or other serializable values to simplify testing and to analyze how state changes over time.
12
+
**ππ½ Instant Feedback**: Fast, interactive watch mode only runs test files related to changed files.
13
+
14
+
**πΈ Snapshot Testing**: Capture snapshots of large objects to simplify testing and to analyze how they change over time.
15
+
16
+
<palign="right"><em>See more on <ahref="https://jestjs.io">jestjs.io</a></em></p>
33
17
34
18
## Getting Started
35
19
@@ -119,25 +103,18 @@ To use [Babel](http://babeljs.io/), install required dependencies via `yarn`:
Configure Babel to target your current version of Node by creating a `babel.config.js` file in the root of your project:
106
+
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:
**The ideal configuration for Babel will depend on your project.** See [Babel's docs](https://babeljs.io/docs/en/) for more details.
115
+
_The ideal configuration for Babel will depend on your project._ See [Babel's docs](https://babeljs.io/docs/en/) for more details.
116
+
117
+
<details><summarymarkdown="span"><strong>Making your Babel config jest-aware</strong></summary>
141
118
142
119
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.
143
120
@@ -162,30 +139,35 @@ module.exports = {
162
139
};
163
140
```
164
141
165
-
#### Babel 6
166
-
167
-
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:
168
-
169
-
```
170
-
"dependencies": {
171
-
"babel-core": "^6.26.3",
172
-
"babel-jest": "^23.6.0",
173
-
"babel-preset-env": "^1.7.0",
174
-
"jest": "^24.0.0"
175
-
}
176
-
```
142
+
</details>
177
143
178
-
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.
144
+
<!-- Note that the Babel 6 section in the Getting Started was removed -->
179
145
180
146
### Using webpack
181
147
182
148
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.
183
149
184
150
### Using TypeScript
185
151
186
-
Jest supports TypeScript out of the box, via Babel.
152
+
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`:
153
+
154
+
```bash
155
+
yarn add --dev @babel/preset-typescript
156
+
```
157
+
158
+
Then add `@babel/preset-typescript` to the list of presets in your `babel.config.js`.
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).
170
+
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).
189
171
190
172
<!-- end copied -->
191
173
@@ -200,7 +182,7 @@ Learn more about using [Jest on the official site!](https://jestjs.io)
200
182
201
183
## Badge
202
184
203
-
Show the world you're using _Jest_β[](https://github.com/facebook/jest)[](https://github.com/facebook/jest)
185
+
Show the world you're using _Jest_`β`[](https://github.com/facebook/jest)[](https://github.com/facebook/jest)
204
186
205
187
```md
206
188
[](https://github.com/facebook/jest) [](https://github.com/facebook/jest)
Copy file name to clipboardExpand all lines: docs/GettingStarted.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,6 +107,8 @@ module.exports = {
107
107
108
108
**The ideal configuration for Babel will depend on your project.** See [Babel's docs](https://babeljs.io/docs/en/) for more details.
109
109
110
+
<details><summarymarkdown="span"><strong>Making your Babel config jest-aware</strong></summary>
111
+
110
112
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.
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:
136
140
@@ -145,6 +149,8 @@ Jest 24 dropped support for Babel 6. We highly recommend you to upgrade to Babel
145
149
146
150
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.
147
151
152
+
</details>
153
+
148
154
### Using webpack
149
155
150
156
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.
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).
178
+
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).
0 commit comments