diff --git a/README.md b/README.md index 2be88aa20..7687b1cb3 100644 --- a/README.md +++ b/README.md @@ -363,6 +363,7 @@ Manually fixable by | [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()` | | | | | | [prefer-comparison-matcher](docs/rules/prefer-comparison-matcher.md) | Suggest using the built-in comparison matchers | | | 🔧 | | | [prefer-each](docs/rules/prefer-each.md) | Prefer using `.each` rather than manual loops | | | | | +| [prefer-ending-with-an-expect](docs/rules/prefer-ending-with-an-expect.md) | Prefer having the last statement in a test be an assertion | | | | | | [prefer-equality-matcher](docs/rules/prefer-equality-matcher.md) | Suggest using the built-in equality matchers | | | | 💡 | | [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | | | 💡 | | [prefer-expect-resolves](docs/rules/prefer-expect-resolves.md) | Prefer `await expect(...).resolves` over `expect(await ...)` syntax | | | 🔧 | | diff --git a/docs/rules/prefer-ending-with-an-expect.md b/docs/rules/prefer-ending-with-an-expect.md new file mode 100644 index 000000000..7c7b6cd81 --- /dev/null +++ b/docs/rules/prefer-ending-with-an-expect.md @@ -0,0 +1,168 @@ +# Prefer having the last statement in a test be an assertion (`prefer-ending-with-an-expect`) + + + +Prefer ending tests with an `expect` assertion. + +## Rule details + +This rule triggers when a test body does not end with an `expect` call, which +can indicate an unfinished test. + +Examples of **incorrect** code for this rule: + +```js +it('lets me change the selected option', () => { + const container = render(MySelect, { + props: { options: [1, 2, 3], selected: 1 }, + }); + + expect(container).toBeDefined(); + expect(container.toHTML()).toContain('