Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: added link to assertion count section in assertion page #15281

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
- `[docs]` Link NestJS documentation on testing with Jest ([#14940](https://github.com/jestjs/jest/pull/14940))
- `[docs]` `Revised documentation for .toHaveBeenCalled()` to accurately depict its functionality. ([#14853](https://github.com/jestjs/jest/pull/14853))
- `[docs]` Removed ExpressJS reference link from documentation due to dead link ([#15270](https://github.com/jestjs/jest/pull/15270))
- `[docs]` Added link to assertion count section in assertion page ([#15281](https://github.com/jestjs/jest/pull/15281))

## 29.7.0

Expand Down
4 changes: 2 additions & 2 deletions docs/TestingAsyncCode.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test('the data is peanut butter', () => {

## Async/Await

Alternatively, you can use `async` and `await` in your tests. To write an async test, use the `async` keyword in front of the function passed to `test`. For example, the same `fetchData` scenario can be tested with:
If you expect a promise to be rejected, use the `.catch` method. Make sure to add `expect.assertions` to verify that a certain number of [assertions](ExpectAPI.md#assertion-count) are called. Otherwise, a fulfilled promise would not fail the test.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes sense to recommend .catch here, as we use catch explicitly


```js
test('the data is peanut butter', async () => {
Expand Down Expand Up @@ -59,7 +59,7 @@ Be sure to return (or `await`) the promise - if you omit the `return`/`await` st

:::

If you expect a promise to be rejected, use the `.catch` method. Make sure to add `expect.assertions` to verify that a certain number of assertions are called. Otherwise, a fulfilled promise would not fail the test.
If you expect a promise to be rejected, use the `.catch` method. Make sure to add `expect.assertions` to verify that a certain number of [assertions](ExpectAPI.md#assertion-count) are called. Otherwise, a fulfilled promise would not fail the test.

```js
test('the fetch fails with an error', () => {
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-29.4/TestingAsyncCode.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Be sure to return (or `await`) the promise - if you omit the `return`/`await` st

:::

If you expect a promise to be rejected, use the `.catch` method. Make sure to add `expect.assertions` to verify that a certain number of assertions are called. Otherwise, a fulfilled promise would not fail the test.
If you expect a promise to be rejected, use the `.catch` method. Make sure to add `expect.assertions` to verify that a certain number of [assertions](ExpectAPI.md#assertion-count) are called. Otherwise, a fulfilled promise would not fail the test.

```js
test('the fetch fails with an error', () => {
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-29.5/TestingAsyncCode.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Be sure to return (or `await`) the promise - if you omit the `return`/`await` st

:::

If you expect a promise to be rejected, use the `.catch` method. Make sure to add `expect.assertions` to verify that a certain number of assertions are called. Otherwise, a fulfilled promise would not fail the test.
If you expect a promise to be rejected, use the `.catch` method. Make sure to add `expect.assertions` to verify that a certain number of [assertions](ExpectAPI.md#assertion-count) are called. Otherwise, a fulfilled promise would not fail the test.

```js
test('the fetch fails with an error', () => {
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-29.6/TestingAsyncCode.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Be sure to return (or `await`) the promise - if you omit the `return`/`await` st

:::

If you expect a promise to be rejected, use the `.catch` method. Make sure to add `expect.assertions` to verify that a certain number of assertions are called. Otherwise, a fulfilled promise would not fail the test.
If you expect a promise to be rejected, use the `.catch` method. Make sure to add `expect.assertions` to verify that a certain number of [assertions](ExpectAPI.md#assertion-count) are called. Otherwise, a fulfilled promise would not fail the test.

```js
test('the fetch fails with an error', () => {
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-29.7/TestingAsyncCode.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Be sure to return (or `await`) the promise - if you omit the `return`/`await` st

:::

If you expect a promise to be rejected, use the `.catch` method. Make sure to add `expect.assertions` to verify that a certain number of assertions are called. Otherwise, a fulfilled promise would not fail the test.
If you expect a promise to be rejected, use the `.catch` method. Make sure to add `expect.assertions` to verify that a certain number of [assertions](ExpectAPI.md#assertion-count) are called. Otherwise, a fulfilled promise would not fail the test.

```js
test('the fetch fails with an error', () => {
Expand Down
Loading