Skip to content

New Rule: test-case-property-name #544

@michaelfaith

Description

@michaelfaith

Proposal

I'd like to propose a new rule that require's the use of a name property in test cases that aren't simple strings. I'm thinking the default behavior would be for it to require it, only if the test case object has options and / or settings defined. If the object just has 'code`, then don't flag it. And then perhaps there's also an option to require it always?

Motivation

The default Ruletester output is usually sufficient when the test cases only consist of the code. But if the test case includes options and / or settings, the code for that test case is likely shared with other test cases (that just have different options / settings applied). In such cases, the output is still just the code. So, if you're trying to track down a failure, and you only have the code from the failure to work with, it can be hard to find the culprit test case.

Here's an example of where we adopted this pattern in eslint-plugin-package-json

Before After
Image Image

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions