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

Rule proposal: no same level suites and tests #104

Open
fleg opened this issue Sep 27, 2016 · 5 comments
Open

Rule proposal: no same level suites and tests #104

fleg opened this issue Sep 27, 2016 · 5 comments

Comments

@fleg
Copy link

fleg commented Sep 27, 2016

Bad

describe('root', function() {
    it('a', function() {});
    it('b', function() {});
    describe('bar', function() {
        it('x', function() {});
        it('y', function() {});
    });
});

Good

describe('root', function() {
    describe('foo', function() {
        it('a', function() {});
        it('b', function() {});
    });

    describe('bar', function() {
        it('x', function() {});
        it('y', function() {});
    });
});
@lo1tuma
Copy link
Owner

lo1tuma commented Sep 27, 2016

@fleg What would be the rationale for such a rule? Is it purely stylistic or are there any problems with having suites and tests at the same level?

@fleg
Copy link
Author

fleg commented Sep 27, 2016

stylistic I guess

@fleg
Copy link
Author

fleg commented Sep 27, 2016

actually mocha do not preserve order for same level suites and tests

describe('root', function() {
    it('a', function() {});
    it('b', function() {});
    describe('bar', function() {
        it('x', function() {});
        it('y', function() {});
    });
    it('q', function() {});
    it('w', function() {});
});
  root
    ✓ a
    ✓ b
    ✓ q
    ✓ w
    bar
      ✓ x
      ✓ y


  6 passing (16ms)

@lo1tuma
Copy link
Owner

lo1tuma commented Sep 29, 2016

Regarding the order of the output of mochas spec reporter, there is already #35 which is a proposal to enforce the same order in the test code.

Anyway I would be ok with I rule that forbids to have tests at the same level as suite. The only thing I wonder if this should be a separate rule than the one suggested in #35 or if they have enough things in common that it could be one generic rule?

@fleg
Copy link
Author

fleg commented Sep 29, 2016

I think it could be one rule with option to forbid same level tests/suites

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

No branches or pull requests

2 participants