Test Naming Standards
Test File Naming
- Unit test files use
.spec.tssuffix - E2E test files use
.spec.tssuffix - Test file directory structure should mirror the source code directory structure
Test Case Naming
Test case naming format: should [expected behavior] [conditions/scenarios]
- Use descriptive names that clearly indicate what is being tested
- Use lowercase for the first letter
- Avoid using "test" at the beginning of test names
Correct Examples:
it('should merge JSON files correctly - basic case', () => {
// ...
})
it('should handle edge case: a has b does not', () => {
// ...
})
Incorrect Examples:
// ❌ Incorrect: Unclear what is being tested
it('test merge', () => {
// ...
})
// ❌ Incorrect: Not descriptive enough
it('merge', () => {
// ...
})
Best Practices
- Be specific: Test names should clearly describe the expected behavior
- Include conditions: When testing edge cases, include the condition in the name
- Use lowercase: Start test names with lowercase letters
- Avoid "test" prefix: The framework already knows it's a test
Converted and distributed by TomeVault — claim your Tome and manage your conversions.