Skip to content

Commit

Permalink
removed useless expect.assertions (#7131)
Browse files Browse the repository at this point in the history
* removed useless expect.assertions

In a lot of case `expect.assertions(1);` is no need. It can be confusing.

* add changelog + some missing case I forgot
  • Loading branch information
Flavien-Pensato authored and rickhanlonii committed Oct 13, 2018
1 parent 9586b12 commit 24880d9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
- `[*]` Bump dated dependencies ([#6978](https://github.com/facebook/jest/pull/6978))
- `[scripts]` Don’t make empty subfolders for ignored files in build folder ([#7001](https://github.com/facebook/jest/pull/7001))
- `[docs]` Add missing export statement in `puppeteer_environment.js` under `docs/Puppeteer.md` ([#7127](https://github.com/facebook/jest/pull/7127))
- `[docs]` Removed useless expect.assertions in `TestingAsyncCode.md` ([#7131](https://github.com/facebook/jest/pull/7131))
- `[docs]` Remove references to `@providesModule` which isn't supported anymore ([#7147](https://github.com/facebook/jest/pull/7147))

## 23.6.0
Expand Down
5 changes: 0 additions & 5 deletions docs/TestingAsyncCode.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ For example, let's say that `fetchData`, instead of using a callback, returns a

```js
test('the data is peanut butter', () => {
expect.assertions(1);
return fetchData().then(data => {
expect(data).toBe('peanut butter');
});
Expand All @@ -73,7 +72,6 @@ You can also use the `.resolves` matcher in your expect statement, and Jest will

```js
test('the data is peanut butter', () => {
expect.assertions(1);
return expect(fetchData()).resolves.toBe('peanut butter');
});
```
Expand All @@ -84,7 +82,6 @@ If you expect a promise to be rejected use the `.rejects` matcher. It works anal

```js
test('the fetch fails with an error', () => {
expect.assertions(1);
return expect(fetchData()).rejects.toMatch('error');
});
```
Expand Down Expand Up @@ -114,12 +111,10 @@ Of course, you can combine `async` and `await` with `.resolves` or `.rejects`.

```js
test('the data is peanut butter', async () => {
expect.assertions(1);
await expect(fetchData()).resolves.toBe('peanut butter');
});

test('the fetch fails with an error', async () => {
expect.assertions(1);
await expect(fetchData()).rejects.toThrow('error');
});
```
Expand Down

0 comments on commit 24880d9

Please sign in to comment.