This document describes the testing setup for the CueMode VS Code extension.
The test suite is organized into several categories:
- Tests the main extension activation and deactivation
- Verifies extension presence and command registration
- Tests the
cuemode.cueModecommand availability - Validates configuration accessibility
- Tests the CueModeExtension class functionality
- Tests the ConfigManager class methods
- Validates
getSafeConfig()returns correct configuration structure - Tests configuration property types (string, number, boolean)
- Validates color theme values against supported themes
- Tests configuration validation logic for:
- fontSize, maxWidth, lineHeight, padding ranges
- scrollSpeed, startingPosition, focusOpacity values
- focusLineCount and focusMode settings
- New focus mode properties (opacity, line count, toggle functionality)
- Tests the ThemeManager class functionality
- Validates all 7 supported themes:
classic,inverted,midnightBlue,sunset,forest,ocean,rose - Tests theme color validation (backgroundColor, textColor)
- Validates CSS color format compliance
- Tests fallback behavior for invalid theme names (returns classic theme)
- Verifies theme structure and property existence
- Tests the i18next-based I18n system
- Validates
initializeI18n()initialization - Tests message key resolution with
t()function - Tests interpolation functionality with variables
- Verifies fallback behavior for missing keys
- Tests language switching across all 6 supported languages:
- English (
en) - Chinese (
zh-CN) - German (
de) - French (
fr) - Japanese (
ja) - Korean (
ko)
- English (
- Validates
changeLanguage()andgetCurrentLanguage()functions - Tests professional teleprompter terminology translations
- Tests the WebViewManager class
- Validates webview creation and lifecycle management
- Tests
isActive(),create(),close(), andupdateConfig()methods - Verifies webview content generation and HTML structure
- Tests configuration updates and theme changes
- Validates CSS generation and style injection
- Tests scroll functionality and content handling
Make sure you have installed all dependencies:
npm installBefore running tests, compile the TypeScript code:
npm run compilenpm testnpm run test:integrationnpm run test:unitYou can run specific test suites by using Mocha directly:
# Run only configuration tests
npx mocha out/test/suite/config.test.js
# Run only theme tests
npx mocha out/test/suite/theme.test.js
# Run only i18n tests
npx mocha out/test/suite/i18n.test.js
# Run only webview tests
npx mocha out/test/suite/webview.test.js
# Run only extension tests
npx mocha out/test/suite/extension.test.js- Framework: Mocha with TDD interface
- Timeout: 10,000ms for each test
- Reporter: Spec reporter with colored output
- File Pattern:
**/**.test.jsin the test directory
- Uses
@vscode/test-electronfor VS Code integration testing - Runs with
--disable-extensionsto avoid conflicts - Extension development path set to project root
- Tests run in isolated VS Code instance
The tests cover the following areas:
- Extension activation and deactivation
- Command registration (
cuemode.cueMode) - Configuration management and validation
- Error handling and fallback behavior
- WebView creation and management
- Theme application and CSS generation
- Content rendering and HTML structure
- Configuration updates and real-time changes
- Message translation with i18next across 6 languages
- Locale switching (English/Chinese/German/French/Japanese/Korean)
- Interpolation with variables
- Fallback handling for missing keys
- Professional teleprompter terminology validation
- Language detection from VS Code environment
- Type checking for all configuration properties
- Range validation for numeric values
- Enum validation for color themes
- Default value handling
- Focus mode configuration validation
- Real-time configuration update testing
- All 7 supported color themes
- CSS color format validation
- Theme structure validation
- Fallback theme handling
When adding new tests:
- Follow the existing structure - Place tests in the appropriate category file
- Use descriptive test names - Test names should clearly describe what is being tested
- Test both positive and negative cases - Include tests for valid and invalid inputs
- Mock external dependencies - Use VS Code API mocks when necessary
- Clean up after tests - Use
suiteTeardown()for proper cleanup - Initialize properly - Use
suiteSetup()for test initialization
suite('Extension Integration Tests', () => {
test('Extension should activate', async () => {
const ext = vscode.extensions.getExtension('luckyXmobile.cuemode');
assert.ok(ext);
await ext.activate();
assert.strictEqual(ext.isActive, true);
});
});suite('ConfigManager Tests', () => {
test('getSafeConfig should return valid configuration', () => {
const config = ConfigManager.getSafeConfig();
assert.ok(config);
assert.strictEqual(typeof config.fontSize, 'number');
});
});suite('ThemeManager Tests', () => {
test('getTheme should return valid theme', () => {
const theme = ThemeManager.getTheme('classic');
assert.ok(theme.backgroundColor);
assert.ok(theme.textColor);
});
});suite('I18n Tests', () => {
test('t should handle interpolation', () => {
const message = t('notifications.themeChanged', { theme: 'Dark' });
assert.ok(message.includes('Dark'));
});
});To debug tests in VS Code:
- Set breakpoints in your test files
- Use the Debug Console to inspect variables
- Run tests with VS Code's integrated test runner
- Use
console.log()for additional debugging output
The tests are designed to run in CI environments:
- No user interaction required
- Proper cleanup after each test
- 10-second timeout for each test
- Graceful handling of missing dependencies
When adding new functionality:
- Write tests first (TDD approach)
- Ensure comprehensive coverage of all code paths
- Test error conditions and edge cases
- Verify proper cleanup and resource disposal
- Update this documentation if needed
-
Tests fail with "Extension not found"
- Ensure the extension is compiled:
npm run compile - Check extension ID matches:
luckyXmobile.cuemode
- Ensure the extension is compiled:
-
WebView tests fail
- Verify mock context is properly set up
- Check VS Code test environment initialization
-
Configuration tests fail
- Ensure default configuration values are valid
- Check validation logic consistency
-
Theme tests fail
- Verify all theme names are correct
- Check CSS color format validation
-
I18n tests fail
- Ensure locale files are copied:
npm run copy-resources - Check i18next initialization
- Verify all 6 language files are present in
src/locales/ - Test language switching functionality
- Ensure locale files are copied:
If you encounter test issues:
- Check the VS Code extension development documentation
- Review similar extensions' test setups
- Create an issue with detailed error information
- Verify TypeScript compilation is successful