From b7aee627b44a37bb115105029db2112d59f96e20 Mon Sep 17 00:00:00 2001 From: Mario Campa Date: Tue, 29 Sep 2020 13:25:09 -0700 Subject: [PATCH] feat(prefer-expect-assertions): adding documetation examples --- docs/rules/prefer-expect-assertions.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/rules/prefer-expect-assertions.md b/docs/rules/prefer-expect-assertions.md index acca6055c..fb1221e1c 100644 --- a/docs/rules/prefer-expect-assertions.md +++ b/docs/rules/prefer-expect-assertions.md @@ -69,3 +69,27 @@ When `true`, this rule will only warn for tests that use the `async` keyword. } } ``` + +When `asyncOnly` option is set to `true`, the following pattern would be a warning: + +```js +test('my test', async () => { + const result = await someAsyncFunc(); + expect(result).toBe('foo'); +}); +``` + +While the following patterns would not be considered warnings: + +```js +test('my test', () => { + const result = someFunction(); + expect(result).toBe('foo'); +}); + +test('my test', async () => { + expect.assertions(1); + const result = await someAsyncFunc(); + expect(result).toBe('foo'); +}); +```