Skip to main content

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
  • For TypeScript:
    • The test file will be named: calculateSum.early.test.ts

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: testcalculateSum.early.test.js
    • Suffix: speccalculateSum.early.spec.js
    Extension Installed

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
  • Kebab Case:
    Converts multi-word names into kebab case (lowercase with hyphens).
    Example:

    • Function Name: calculateSum
    • Test File Name: calculate-sum.early.test.js

Example for Multi-Word Function Names:

  • Function Name: processDataChunk

    • Camel Case → processDataChunk.early.test.js
    • Kebab Case → process-data-chunk.early.test.js
    Extension Installed

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

With these configurations, Early AI provides the flexibility to align test file names with your project's conventions while maintaining clarity and organization.