Feature request: Disallow describe.only and it.only
jlherren opened this issue · comments
According to the Cypress docs, one recommended way to write tests is to temporarily use describe.only
and/or it.only
to only run the single test currently being written.
If I understand the concept correctly, these two functions are useful while writing tests, but should never be committed to version history. However, that happens way to easily by accident, if we forget to remove the .only
part. I therefore propose a new rule to disallow these functions entirely. (.skip
probably shouldn't be included here, as it makes sense to commit an incomplete test.)
Thanks! So to sum up, it was considered a great idea, but somehow never happened. I'll give eslint-plugin-no-only-tests a try in the meantime.
Isn't the main runner in cypress actually mocha? - in which case why not use the mocha rules found in https://www.npmjs.com/package/eslint-plugin-mocha and just recommend that develkopers of cypress tests use those rules too?
There's lots of other useful lint rules in there too which should be useful for cypress like no-identical-title.
Much as it's not cypress's job to rewrite a test runner it's not really cypress's job to mirror those rules.
Wouldn't a simpler approach for eslint-plugin-cypress be to express it's remit and recommend other eslint-plugins ?
This would duplicate the rule
https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-exclusive-tests.md
https://github.com/cypress-io/cypress-example-kitchensink/blob/master/.eslintrc shows an example of the two plugins working side-by-side to achieve the goal of flagging describe.only
and it.only
eslint-plugin-mocha
eslint-plugin-cypress
See also the comments in
- PR #25
where it was decided not to duplicate the functionality from eslint-plugin-mocha
and put it into eslint-plugin-cypress
.