Skip to content
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

Rules proposal: one describe per file #103

Closed
alecxe opened this issue Sep 25, 2016 · 4 comments
Closed

Rules proposal: one describe per file #103

alecxe opened this issue Sep 25, 2016 · 4 comments

Comments

@alecxe
Copy link
Contributor

alecxe commented Sep 25, 2016

The rationale and the use case we have is described here Enforce one describe per file.

To summarize - the rule should produce a warning if there is more than one top-level describe per file.

Probably, we have too narrow of a use case - feel free to close if you feel there is no need for this kind of rule. Or, may be we can just turn it off by default.

Thanks!

@lo1tuma
Copy link
Owner

lo1tuma commented Sep 27, 2016

Hi @alecxe, thanks for the suggestion. I like the idea and would probably use such a rule as I’m already restrict my test files to only have one top-level describe 😉 .

Just for completeness: there are of course some limitations to static analysis in JavaScript where not all top-level describes can be detected. For example when someone creates test suites dynamically:

function createTestCases(name) {
    describe(name, function () {
        // tests ...
    });
}

createTestCases('foo');
createTestCases('bar');

alecxe added a commit to alecxe/eslint-plugin-mocha that referenced this issue Sep 28, 2016
alecxe added a commit to alecxe/eslint-plugin-mocha that referenced this issue Sep 28, 2016
@jfmengels
Copy link
Collaborator

FYI, this is kind of similar to #83.

@lo1tuma
Copy link
Owner

lo1tuma commented Sep 29, 2016

@jfmengels Good hint. I guess this rule together with a no-nested-describes rule would give you the behavior that you can only use one describe per file.

@jfmengels
Copy link
Collaborator

Ah, good point. Fine by me then 👍

lo1tuma added a commit that referenced this issue Oct 3, 2016
@lo1tuma lo1tuma closed this as completed Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants