title: Jest
category: JavaScript libraries
layout: 2017/sheet
-updated: 2017-09-01
+updated: 2020-06-17
weight: -3
tags: [Featurable]
intro: |
npm test -- --watch
```
-See: [Getting started](http://facebook.github.io/jest/docs/en/getting-started.html)
+See: [Getting started](https://facebook.github.io/jest/docs/en/getting-started.html)
### Writing tests
})
```
-See: [describe()](http://facebook.github.io/jest/docs/en/api.html#describename-fn), [test()](http://facebook.github.io/jest/docs/en/api.html#testname-fn), [expect()](http://facebook.github.io/jest/docs/en/expect.html#content)
+See: [describe()](https://facebook.github.io/jest/docs/en/api.html#describename-fn), [test()](https://facebook.github.io/jest/docs/en/api.html#testname-fn), [expect()](https://facebook.github.io/jest/docs/en/expect.html#content)
### BDD syntax
```
`it` is an alias for `test`.
-See: [test()](http://facebook.github.io/jest/docs/en/api.html#testname-fn)
+See: [test()](https://facebook.github.io/jest/docs/en/api.html#testname-fn)
### Setup
afterAll(() => { ... })
```
-See: [afterAll() and more](http://facebook.github.io/jest/docs/en/api.html#afterallfn)
+See: [afterAll() and more](https://facebook.github.io/jest/docs/en/api.html#afterallfn)
### Focusing tests
it.only(···) // alias: fit()
```
-See: [test.only](http://facebook.github.io/jest/docs/en/api.html#testonlyname-fn)
+See: [test.only](https://facebook.github.io/jest/docs/en/api.html#testonlyname-fn)
### Skipping tests
it.skip(···) // alias: xit()
```
-See: [test.skip](http://facebook.github.io/jest/docs/en/api.html#testskipname-fn)
+See: [test.skip](https://facebook.github.io/jest/docs/en/api.html#testskipname-fn)
### Optional flags
```
Note that `toEqual` is a deep equality check.
-See: [expect()](http://facebook.github.io/jest/docs/en/expect.html#expectvalue)
+See: [expect()](https://facebook.github.io/jest/docs/en/expect.html#expectvalue)
### Snapshots
{: data-line="2"}
Return promises, or use async/await.
-See: [Async tutorial](http://facebook.github.io/jest/docs/en/tutorial-async.html)
+See: [Async tutorial](https://facebook.github.io/jest/docs/en/tutorial-async.html)
### Snapshots
{: data-line="3"}
First run creates a snapshot. Subsequent runs match the saved snapshot.
-See: [Snapshot testing](http://facebook.github.io/jest/docs/en/snapshot-testing.html)
+See: [Snapshot testing](https://facebook.github.io/jest/docs/en/snapshot-testing.html)
### React test renderer
```jsx
it('works', () => {
const tree = renderer.create(
- <Link page="http://www.facebook.com">Facebook</Link>
+ <Link page="https://www.facebook.com">Facebook</Link>
).toJSON()
expect(tree).toMatchSnapshot()
{: data-line="2,3,4"}
React's test renderer can be used for Jest snapshots.
-See: [Snapshot test](http://facebook.github.io/jest/docs/en/tutorial-react-native.html#snapshot-test)
+See: [Snapshot test](https://facebook.github.io/jest/docs/en/tutorial-react-native.html#snapshot-test)
### Timers
})
```
-See: [Timer Mocks](http://facebook.github.io/jest/docs/en/timer-mocks.html)
+See: [Timer Mocks](https://facebook.github.io/jest/docs/en/timer-mocks.html)
## Mock functions
const fn = jest.fn(n => n * n)
```
-See: [Mock functions](http://facebook.github.io/jest/docs/en/mock-functions.html#using-a-mock-function)
+See: [Mock functions](https://facebook.github.io/jest/docs/en/mock-functions.html#using-a-mock-function)
### Assertions
```
{: data-line="1"}
-See: [.mock property](http://facebook.github.io/jest/docs/en/mock-functions.html#mock-property)
+See: [.mock property](https://facebook.github.io/jest/docs/en/mock-functions.html#mock-property)
### Calls
```
{: data-line="1,2,3"}
-See: [.mock property](http://facebook.github.io/jest/docs/en/mock-functions.html#mock-property)
+See: [.mock property](https://facebook.github.io/jest/docs/en/mock-functions.html#mock-property)
### Return values
## References
{: .-one-column}
-- <http://facebook.github.io/jest/>
+- <https://facebook.github.io/jest/>
{: .-also-see}