ESLint version
v9.30.1
What problem do you want to solve?
I try to improve the quality of some (invalid) rule tests, by making sure they all test the same properties.
Specifically I want to ensure, I (and future developers) test for
- individual errors instead of error counts
- and test for specific error messages and locations instead of partial checks
What do you think is the correct solution?
I have considered two similar solutions:
- Add
assertionOptions/options: { requireMessage: boolean; requireLocation: boolean } to RuleTester constructor
- Add
assertionOptions/options: { requireMessage: boolean; requireLocation: boolean; requiredBlocks: Array<'valid', 'invalid'> } to RuleTester's run method
The second option would make it possible to run multiple test runs with the same runner instance but different options.
Participation
Additional comments
Requiring the location would require the full location (might be configurable with boolean | 'full')
Continuation of #19904
ESLint version
v9.30.1
What problem do you want to solve?
I try to improve the quality of some (invalid) rule tests, by making sure they all test the same properties.
Specifically I want to ensure, I (and future developers) test for
What do you think is the correct solution?
I have considered two similar solutions:
assertionOptions/options: { requireMessage: boolean; requireLocation: boolean }toRuleTesterconstructorassertionOptions/options: { requireMessage: boolean; requireLocation: boolean; requiredBlocks: Array<'valid', 'invalid'> }toRuleTester'srunmethodThe second option would make it possible to run multiple test runs with the same runner instance but different options.
Participation
Additional comments
Requiring the location would require the full location (might be configurable with
boolean | 'full')Continuation of #19904