Open
Description
Suggestion
Problem
no-unused-vars-eslint.test.ts
andno-unused-vars.test.ts
has many lines & test case (over 3000 lines!).- As it is a complex and frequently used rule, the number of test cases increases over time.
- Risk of writing duplicate test cases.
- Possibility that test cases will be forgotten even if they are weird.
- Difficulty knowing which test cases cover which code
- Risk that these are test cases for related features but are far apart in the file
Solution
Separate test cases with describe block.
This is my opinion. In some cases, these are mixed.
order of describe layer | description |
---|---|
1 | messageId |
2 | action |
additional | option, test cases for weird bug, special syntax |
Example
ex is just ex.
describe('unusedVar',() => {
describe('defined action',()=>{
describe('import statement',()=>{
ruleTester.run('no-unused-vars', rule, {
})
})
})
})
Additional Info
This is example of separated test cases: prefer-optional-chain