Description
While analyzing the asyncapi-generator codebase, I identified several areas where the test suite can be improved to increase reliability and catch potential regressions early.
Currently:
- Some core modules like
conditionalGeneration.js lack dedicated unit tests.
- Certain integration test scenarios (such as log verification for
noOverwriteGlobs) are marked with TODOs.
Strengthening these areas will improve confidence in future changes and refactors.
Proposed Improvements
1. Dedicated Unit Tests for conditionalGeneration.js
The lib/conditionalGeneration.js module handles complex logic for conditional file/folder generation using template parameters and JMESPath expressions.
Goal: Create
apps/generator/test/conditionalGeneration.test.js
to cover:
Scenarios
- Parameter-based conditions.
- Subject (JMESPath) based conditions.
- Handling of the deprecated
conditionalFiles configuration.
Edge Cases
- Missing parameters in
templateParams.
- JMESPath expressions returning no results or
null.
- Custom
validate functions in conditionalGeneration.
- Server-specific context in JMESPath evaluation.
2. Verify Log Messages in Integration Tests
An existing TODO in test/integration.test.js suggests verifying log messages when files are skipped due to noOverwriteGlobs.
Goal: Implement log spying using:
To ensure:
logMessage.relativeSourceFileNotGenerated (or the corresponding overwrite-skip message) is correctly called.
- Users get visual feedback in debug mode when files are intentionally skipped.
3. Expand noOverwriteGlobs Scenarios
Current integration tests for noOverwriteGlobs cover only basic cases.
Goal: Add more complex scenarios to
apps/generator/test/integration.test.js, including:
- Nested directory structures.
- Multiple glob patterns.
- Overlapping globs.
Impact
These improvements will:
- Increase overall test coverage of the generator core.
- Ensure the transition from
conditionalFiles → conditionalGeneration is stable.
- Improve developer experience by confirming debug logs behave as expected.
Next Steps
Description
While analyzing the asyncapi-generator codebase, I identified several areas where the test suite can be improved to increase reliability and catch potential regressions early.
Currently:
conditionalGeneration.jslack dedicated unit tests.noOverwriteGlobs) are marked with TODOs.Strengthening these areas will improve confidence in future changes and refactors.
Proposed Improvements
1. Dedicated Unit Tests for
conditionalGeneration.jsThe
lib/conditionalGeneration.jsmodule handles complex logic for conditional file/folder generation using template parameters and JMESPath expressions.Goal: Create
apps/generator/test/conditionalGeneration.test.jsto cover:
Scenarios
conditionalFilesconfiguration.Edge Cases
templateParams.null.validatefunctions inconditionalGeneration.2. Verify Log Messages in Integration Tests
An existing TODO in
test/integration.test.jssuggests verifying log messages when files are skipped due tonoOverwriteGlobs.Goal: Implement log spying using:
To ensure:
logMessage.relativeSourceFileNotGenerated(or the corresponding overwrite-skip message) is correctly called.3. Expand
noOverwriteGlobsScenariosCurrent integration tests for
noOverwriteGlobscover only basic cases.Goal: Add more complex scenarios to
apps/generator/test/integration.test.js, including:Impact
These improvements will:
conditionalFiles→conditionalGenerationis stable.Next Steps
Create
apps/generator/test/conditionalGeneration.test.js.Update
apps/generator/test/integration.test.jswith:Ensure all existing tests pass.