Test File Naming Conventions & Customization
Early AI follows a standardized naming convention for test files to ensure clarity and consistency. This guide explains the default naming format and the customization options available in the extension’s settings.
Default Naming Convention
The test file name is derived from the function name using the following format: .early..js or ts
Example:
- For a function named
calculateSum
in a JavaScript file:- The test file will be named:
calculateSum.early.test.js
- The test file will be named:
- For TypeScript:
- The test file will be named:
calculateSum.early.test.ts
- The test file will be named:
Handling Duplicate Test Files:
If tests are generated multiple times for the same function, Early AI automatically appends a counter to the filename to prevent overwriting:
- Second Test File:
calculateSum1.early.test.js
- Third Test File:
calculateSum2.early.test.js
Customizing Test File Names
In the extension’s settings, you can customize the naming conventions for test files through two configurations:
1. Test Suffix
This setting allows you to choose the suffix used in test file names. Options are:
- test (default): Generates test files with the
.early.test.js
or.early.test.ts
suffix. - spec: Generates test files with the
.early.spec.js
or.early.spec.ts
suffix.
Example:
-
Function Name:
calculateSum
- Suffix:
test
→calculateSum.early.test.js
- Suffix:
spec
→calculateSum.early.spec.js
- Suffix:
2. Test File Name Case
This setting determines how multi-word function names are formatted in the test file name. Options are:
-
Camel Case (default):
Converts multi-word names into camel case.
Example:- Function Name:
calculateSum
- Test File Name:
calculateSum.early.test.js
- Function Name:
-
Kebab Case:
Converts multi-word names into kebab case (lowercase with hyphens).
Example:- Function Name:
calculateSum
- Test File Name:
calculate-sum.early.test.js
- Function Name:
Example for Multi-Word Function Names:
-
Function Name:
processDataChunk
- Camel Case →
processDataChunk.early.test.js
- Kebab Case →
process-data-chunk.early.test.js
- Camel Case →
Notes
- Extension View: Both configurations are available in the Settings view of the Early AI extension.
- Consistency: These options allow you to maintain consistency across your project based on your team’s preferences.
- Defaults: The default options are:
- Test Suffix:
test
- Test File Name Case:
Camel Case
- Test Suffix:
With these configurations, Early AI provides the flexibility to align test file names with your project's conventions while maintaining clarity and organization.