|
| 1 | +--- |
| 2 | +description: Naming conventions for test files, directories, and test descriptions across the project |
| 3 | +alwaysApply: false |
| 4 | +globs: |
| 5 | + - '**/*.test.ts' |
| 6 | + - '**/*.test.js' |
| 7 | + - '**/*.cy.js' |
| 8 | + - '**/*.cy.ts' |
| 9 | + - '**/*.spec.ts' |
| 10 | + - '**/*.spec.js' |
| 11 | + - '**/cypress/**' |
| 12 | + - '**/__tests__/**' |
| 13 | +--- |
| 14 | + |
| 15 | +# Test Naming Conventions |
| 16 | + |
| 17 | +## Cypress E2E Tests (`cypress/e2e/`) |
| 18 | + |
| 19 | +### Directories |
| 20 | + |
| 21 | +- **kebab-case only**: `copy-paste/`, `heading/`, `keyboard-shortcuts/` |
| 22 | +- Never PascalCase or camelCase for directories |
| 23 | + |
| 24 | +### Files |
| 25 | + |
| 26 | +- **kebab-case only**: `clipboard-validation.cy.js`, `bullet-list.cy.js` |
| 27 | +- Never PascalCase (`BulletList.cy.js`) or camelCase (`bulletList.cy.js`) |
| 28 | +- No `e2e-` prefix — files are already inside `cypress/e2e/`, the prefix is redundant |
| 29 | +- No numeric prefixes for ordering unless there is a documented reason |
| 30 | + |
| 31 | +### Examples |
| 32 | + |
| 33 | +``` |
| 34 | +# CORRECT |
| 35 | +cypress/e2e/editor/formatting/bold.cy.js |
| 36 | +cypress/e2e/editor/lists/task-list.cy.js |
| 37 | +cypress/e2e/editor/heading/change/heading-level-change-complex.cy.js |
| 38 | + |
| 39 | +# WRONG |
| 40 | +cypress/e2e/editor/Formatting/Bold.cy.js # PascalCase dir + file |
| 41 | +cypress/e2e/editor/lists/TaskList.cy.js # PascalCase file |
| 42 | +cypress/e2e/editor/e2e-heading-change.cy.js # redundant e2e- prefix |
| 43 | +``` |
| 44 | + |
| 45 | +## Unit Tests (`__tests__/`) |
| 46 | + |
| 47 | +### Files |
| 48 | + |
| 49 | +- **camelCase**: matches the source module being tested |
| 50 | +- Pattern: `<moduleName>.test.ts` |
| 51 | +- Name describes the **module or concern**, not the project phase or sprint |
| 52 | +- Performance tests: `<moduleName>.performance.test.ts` |
| 53 | + |
| 54 | +### Examples |
| 55 | + |
| 56 | +``` |
| 57 | +# CORRECT — name matches the module |
| 58 | +findPrevBlock.test.ts → tests findPrevBlock.ts |
| 59 | +copyPastePlugin.test.ts → tests createCopyPastePlugin |
| 60 | +validateHeadingHierarchy.test.ts → tests validateHeadingHierarchy.ts |
| 61 | + |
| 62 | +# WRONG — name describes a sprint/phase |
| 63 | +auditFixes.test.ts → name says nothing about what it tests |
| 64 | +sprintFixes.test.ts → same problem |
| 65 | +``` |
| 66 | + |
| 67 | +## Cypress Support & Fixtures |
| 68 | + |
| 69 | +- **Support files** (commands, validators): camelCase — these are JS/TS modules (`schemaValidator.js`) |
| 70 | +- **Fixture directories**: camelCase when mirroring a command name (`createSelection/`) is acceptable |
| 71 | +- **Fixture files** (HTML, JSON): kebab-case (`basic-single-section-document.html`) |
| 72 | + |
| 73 | +## Test Descriptions |
| 74 | + |
| 75 | +- Use `it()` everywhere — never `test()` |
| 76 | +- Describe behavior, not ticket IDs: `'merges first block into heading on backspace'` not `'fixes #1234'` |
| 77 | +- Use `should` prefix OR bare verb consistently within a file — do not mix |
0 commit comments