eslint-plugin-mocha icon indicating copy to clipboard operation
eslint-plugin-mocha copied to clipboard

Rule proposal: consistent order of tests

Open lo1tuma opened this issue 10 years ago • 2 comments

The spec reporter from Mocha always outputs the test results of the current describe block before the results of subsequent describe blocks.

I would like to have a rule to reflect the same order in the code:

  • describe
    • before / after hooks
    • it
    • it
    • describe

This would be an invalid order:

  • describe
    • before / after hooks
    • describe
    • it

Maybe we should consider a separate rule that requires the position of before /after hooks on top of a describe block.

lo1tuma avatar Sep 13 '15 10:09 lo1tuma

This would be great. I'd also like this or another rule to enforce order of different types of hooks. E.g.:

Valid order:

  • describe
    • before
    • after
    • beforeEach
    • afterEach

Valid with configuration:

  • describe
    • before
    • beforeEach
    • afterEach
    • after

Invalid order:

  • describe
    • after
    • beforeEach
    • before
    • afterEach

willclarktech avatar Sep 08 '17 15:09 willclarktech

I opened an issue about that separate rule as https://github.com/lo1tuma/eslint-plugin-mocha/issues/193

oprogramador avatar Jun 20 '19 01:06 oprogramador