eslint-plugin-mocha
eslint-plugin-mocha copied to clipboard
Rule proposal: consistent order of tests
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.
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
I opened an issue about that separate rule as https://github.com/lo1tuma/eslint-plugin-mocha/issues/193