From 3e94e51c696e09c43cd759504ad09696a1241226 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 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/rules/prefer-expect-assertions.md b/docs/rules/prefer-expect-assertions.md index acca6055c..76dd9cfb9 100644 --- a/docs/rules/prefer-expect-assertions.md +++ b/docs/rules/prefer-expect-assertions.md @@ -69,3 +69,28 @@ 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'); +}); +```