From 5f4cc6084ff0654eb78e0034a83f37af902bd349 Mon Sep 17 00:00:00 2001 From: Michael Gentry Date: Tue, 29 Jun 2021 17:50:43 -0400 Subject: [PATCH 1/2] Add await to doAsync to allow doAsync to complete before returning The test would always fail if doAsync is an actual async function. --- website/versioned_docs/version-27.0/ExpectAPI.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/versioned_docs/version-27.0/ExpectAPI.md b/website/versioned_docs/version-27.0/ExpectAPI.md index 43a39820e975..9503a3f029c6 100644 --- a/website/versioned_docs/version-27.0/ExpectAPI.md +++ b/website/versioned_docs/version-27.0/ExpectAPI.md @@ -406,7 +406,7 @@ describe('Beware of a misunderstanding! A sequence of dice rolls', () => { For example, let's say that we have a function `doAsync` that receives two callbacks `callback1` and `callback2`, it will asynchronously call both of them in an unknown order. We can test this with: ```js -test('doAsync calls both callbacks', () => { +test('doAsync calls both callbacks', async () => { expect.assertions(2); function callback1(data) { expect(data).toBeTruthy(); @@ -415,7 +415,7 @@ test('doAsync calls both callbacks', () => { expect(data).toBeTruthy(); } - doAsync(callback1, callback2); + await doAsync(callback1, callback2); }); ``` From a6e312df6d721a91f61bfef1f797e6c186a49064 Mon Sep 17 00:00:00 2001 From: Michael Gentry Date: Tue, 29 Jun 2021 18:02:08 -0400 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a3578e203f1..a6b1d88a6a8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ ### Performance +## 27.0.7 + +### Chore & Maintenance + +- `[docs]` Correct expects.assertions documentation by adding async/await for asynchronous function. + ## 27.0.6 ### Fixes