Skip to content

Elaborate on output test assertion requirement and benefits in consistent-output rule doc #123

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

Merged
merged 1 commit into from
Jun 14, 2021
Merged
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
6 changes: 5 additions & 1 deletion docs/rules/consistent-output.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

When writing tests for a fixable rule with `RuleTester`, you can assert the autofix output of your test cases. However, it can be easy to forget to assert the output of a particular test case.

[As of ESLint 7](https://eslint.org/docs/user-guide/migrating-to-7.0.0#additional-validation-added-to-the-ruletester-class), test cases that trigger an autofix are required to provide the `output` property.

Even test that do not trigger an autofix can benefit from asserting that they have no autofix using `output: null`.

## Rule Details

This rule aims to ensure that if any invalid test cases have output assertions, then all test cases have output assertions.
Expand Down Expand Up @@ -48,7 +52,7 @@ new RuleTester().run('example-rule', rule, {
},
{
code: 'foo',
output: null,
output: null, // asserts that there is no autofix
errors: ['baz']
}
]
Expand Down