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

False positive in mocha/max-top-level-suites #224

Closed
zachlysobey opened this issue Dec 15, 2019 · 2 comments · Fixed by #239
Closed

False positive in mocha/max-top-level-suites #224

zachlysobey opened this issue Dec 15, 2019 · 2 comments · Fixed by #239
Labels

Comments

@zachlysobey
Copy link

I noticed that the mocha/max-top-level-suites rule seems to trigger erroneously if there is a function which generates nested describes outside of the scope of the top-level-suite.

describe("top-level describe", () => {
  it("has some tests");
  addNestedDescribe();
});

function addNestedDescribe() {
  describe("added nested describe", () => {
    it("has more tests");
  });
}

This creates the following output (notice, only one top-level describe)

top-level describe
- has some tests
  added nested describe
  - has more tests

But the rule still causes an error.

reproduction-of-bug.spec.js
  7:5  error    The number of top-level suites is more than 1  mocha/max-top-level-suites

It seems that this can be resolved in my case by moving that function inside of the top-level describe callback, but I would generally prefer not to have to do that.

@lo1tuma lo1tuma added the bug label Dec 15, 2019
@lo1tuma
Copy link
Owner

lo1tuma commented Dec 15, 2019

Thanks for reporting. Looks like a bug to me.

@zachlysobey
Copy link
Author

I should note, that I'd be willing to help out with this. I'm not sure if I have the AST chops to fix it, but I could certainly write a failing unit test, or add a note to the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants