| 1 | # Disallow commented out tests (`no-commented-out-tests`)
|
|---|
| 2 |
|
|---|
| 3 | This rule raises a warning about commented out tests. It's similar to
|
|---|
| 4 | no-disabled-tests rule.
|
|---|
| 5 |
|
|---|
| 6 | ## Rule Details
|
|---|
| 7 |
|
|---|
| 8 | The rule uses fuzzy matching to do its best to determine what constitutes a
|
|---|
| 9 | commented out test, checking for a presence of `it(`, `describe(`, `it.skip(`,
|
|---|
| 10 | etc. in code comments.
|
|---|
| 11 |
|
|---|
| 12 | The following patterns are considered warnings:
|
|---|
| 13 |
|
|---|
| 14 | ```js
|
|---|
| 15 | // describe('foo', () => {});
|
|---|
| 16 | // it('foo', () => {});
|
|---|
| 17 | // test('foo', () => {});
|
|---|
| 18 |
|
|---|
| 19 | // describe.skip('foo', () => {});
|
|---|
| 20 | // it.skip('foo', () => {});
|
|---|
| 21 | // test.skip('foo', () => {});
|
|---|
| 22 |
|
|---|
| 23 | // describe['skip']('bar', () => {});
|
|---|
| 24 | // it['skip']('bar', () => {});
|
|---|
| 25 | // test['skip']('bar', () => {});
|
|---|
| 26 |
|
|---|
| 27 | // xdescribe('foo', () => {});
|
|---|
| 28 | // xit('foo', () => {});
|
|---|
| 29 | // xtest('foo', () => {});
|
|---|
| 30 |
|
|---|
| 31 | /*
|
|---|
| 32 | describe('foo', () => {});
|
|---|
| 33 | */
|
|---|
| 34 | ```
|
|---|
| 35 |
|
|---|
| 36 | These patterns would not be considered warnings:
|
|---|
| 37 |
|
|---|
| 38 | ```js
|
|---|
| 39 | describe('foo', () => {});
|
|---|
| 40 | it('foo', () => {});
|
|---|
| 41 | test('foo', () => {});
|
|---|
| 42 |
|
|---|
| 43 | describe.only('bar', () => {});
|
|---|
| 44 | it.only('bar', () => {});
|
|---|
| 45 | test.only('bar', () => {});
|
|---|
| 46 |
|
|---|
| 47 | // foo('bar', () => {});
|
|---|
| 48 | ```
|
|---|
| 49 |
|
|---|
| 50 | ### Limitations
|
|---|
| 51 |
|
|---|
| 52 | The plugin looks at the literal function names within test code, so will not
|
|---|
| 53 | catch more complex examples of commented out tests, such as:
|
|---|
| 54 |
|
|---|
| 55 | ```js
|
|---|
| 56 | // const testSkip = test.skip;
|
|---|
| 57 | // testSkip('skipped test', () => {});
|
|---|
| 58 |
|
|---|
| 59 | // const myTest = test;
|
|---|
| 60 | // myTest('does not have function body');
|
|---|
| 61 | ```
|
|---|