Troubleshooting Guide
Common Issues and Solutions
This comprehensive guide helps you resolve common issues with adaptive-tests across all supported languages and frameworks.
Table of Contents
- Discovery Issues
- Performance Problems
- Language-Specific Issues
- VS Code Extension Issues
- CI/CD Problems
- Error Messages
Discovery Issues
“No candidates found for signature”
Symptoms:
Error: No candidates found for signature {"name":"MyComponent"}
Solutions:
- Check the exact export name:
# See what's actually exported
npx adaptive-tests analyze src/components/MyComponent.js
- Use the Discovery Lens to debug:
# See why discovery is failing
npx adaptive-tests why '{"name":"MyComponent"}' --json
- Verify file is in search path:
const Component = await discover({
name: 'MyComponent'
}, {
searchPaths: ['./src', './components', './lib'],
verbose: true // See where it's searching
});
- Check for case sensitivity issues:
// Wrong - case mismatch
{ name: 'mycomponent' }
// Correct - exact case
{ name: 'MyComponent' }
“Multiple candidates found, ambiguous match”
Problem: Multiple files export the same name
Solutions:
- Add more specific criteria:
const Service = await discover({
name: 'UserService',
type: 'class',
methods: ['login', 'logout'], // More specific
path: 'services' // Path hint
});
- Use full path matching:
const Service = await discover({
name: 'UserService',
fullPath: 'src/services/UserService.js'
});
Discovery is too slow
Solutions:
- Enable caching:
// In jest.setup.js or test setup
const { enablePersistentCache } = require('adaptive-tests');
enablePersistentCache({
cacheDir: '.adaptive-cache',
maxAge: 86400000 // 24 hours
});
- Limit search scope:
// Don't search node_modules or build directories
const engine = getDiscoveryEngine(process.cwd(), {
ignore: ['**/node_modules/**', '**/dist/**', '**/build/**'],
maxDepth: 5
});
- Use specific file extensions:
const Component = await discover({
name: 'Component'
}, {
extensions: ['.tsx', '.jsx'], // Don't check .js, .ts, etc.
});
Performance Problems
Tests run slowly
Solutions:
- Parallelize test execution:
// package.json
{
"scripts": {
"test": "jest --maxWorkers=50%"
}
}
- Cache discovery results between runs:
// jest.config.js
module.exports = {
globals: {
'adaptive-tests': {
cache: true,
cacheDirectory: '.jest-adaptive-cache'
}
}
};
- Pre-warm the cache:
# Run before tests to build cache
npx adaptive-tests warm --all
Memory leaks during testing
Symptoms: Tests consume increasing memory, eventual crash
Solutions:
- Clear cache between test suites:
afterAll(() => {
const { clearCache } = require('adaptive-tests');
clearCache();
});
- Limit cache size:
const { setMaxCacheSize } = require('adaptive-tests');
setMaxCacheSize(100); // Max 100 cached modules
- Use worker isolation:
// jest.config.js
{
"testRunner": "jest-runner-isolated"
}
Language-Specific Issues
JavaScript/TypeScript
Issue: “Cannot use import statement outside a module”
Solution:
// package.json
{
"type": "module"
}
Or use Babel:
// babel.config.js
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }]
]
};
Issue: TypeScript types not found
Solution:
npm install --save-dev ts-node @types/node
// tsconfig.json
{
"compilerOptions": {
"esModuleInterop": true,
"allowJs": true,
"resolveJsonModule": true
}
}
Java
Issue: “Maven project not detected”
Solution:
# Ensure pom.xml exists
ls pom.xml
# Install Java CLI
cd languages/java
mvn clean install
Issue: “Package structure doesn’t match”
Solution: Ensure proper Maven/Gradle structure:
src/
├── main/
│ └── java/
│ └── com/example/YourClass.java
└── test/
└── java/
└── com/example/YourClassTest.java
PHP
Issue: “Composer autoload not found”
Solution:
composer install
composer dump-autoload
Issue: “PHPUnit not configured”
Solution:
<!-- phpunit.xml -->
<phpunit bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="adaptive">
<directory>tests/adaptive</directory>
</testsuite>
</testsuites>
</phpunit>
Python
Issue: “Module not found”
Solution:
# Add project to Python path
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
# Or in test file
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
Issue: “Invalid signature for Python”
Solution: Use Python-specific signatures:
# discover.json
{
"name": "Calculator",
"type": "class",
"methods": ["add", "subtract"],
"module": "src.utils.calculator"
}
VS Code Extension Issues
Extension not activating
Solutions:
- Check extension logs:
- Open Command Palette:
Cmd/Ctrl + Shift + P
- Run: “Developer: Show Extension Logs”
- Select: “Adaptive Tests”
- Open Command Palette:
- Reload VS Code window:
- Command Palette: “Developer: Reload Window”
- Check workspace trust:
- Ensure workspace is trusted
- Check: File > Preferences > Settings > Security
Discovery Lens not showing results
Solutions:
- Verify adaptive-tests is installed:
npm list adaptive-tests
- Check webview developer tools:
- Command Palette: “Developer: Open Webview Developer Tools”
- Check for JavaScript errors
- Reset extension state:
- Command Palette: “Adaptive Tests: Reset State”
CodeLens not appearing
Solutions:
- Enable CodeLens in settings:
// .vscode/settings.json
{
"editor.codeLens": true,
"adaptive-tests.codeLens.enabled": true
}
- Check file type is supported:
- Supported: .js, .jsx, .ts, .tsx, .java, .php, .py
- Not supported: .vue, .svelte (yet)
CI/CD Problems
Tests fail in CI but pass locally
Common causes:
- Different Node.js versions:
# .github/workflows/test.yml
- uses: actions/setup-node@v3
with:
node-version: '18' # Match local version
- Missing dependencies:
- run: npm ci # Use ci instead of install
- File path case sensitivity:
// Wrong - works on Windows/Mac, fails on Linux
import Component from './MyComponent';
// Correct - exact case
import Component from './myComponent';
GitHub Actions timeout
Solutions:
jobs:
test:
timeout-minutes: 30 # Increase timeout
steps:
- uses: actions/cache@v3
with:
path: |
~/.npm
.adaptive-cache
key: $-adaptive-$
Error Messages
“ENOENT: no such file or directory”
Cause: File path issues, often on Windows
Solution:
// Use path.join instead of string concatenation
const path = require('path');
const testPath = path.join(__dirname, 'tests', 'adaptive');
“Cannot read property ‘discover’ of undefined”
Cause: Incorrect import
Solution:
// Wrong
import discover from 'adaptive-tests';
// Correct
import { discover } from 'adaptive-tests';
// or
const { discover } = require('adaptive-tests');
“Maximum call stack exceeded”
Cause: Circular dependencies or infinite recursion
Solution:
// Add cycle detection
const { discover } = require('adaptive-tests');
const Module = await discover({
name: 'Module'
}, {
detectCycles: true,
maxDepth: 10
});
“Jest encountered an unexpected token”
Cause: ES6 modules not transpiled
Solution:
// jest.config.js
module.exports = {
transform: {
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
},
transformIgnorePatterns: [
'node_modules/(?!(adaptive-tests)/)'
]
};
Debug Mode
Enable verbose logging for detailed troubleshooting:
# Set environment variable
DEBUG=adaptive-tests:* npm test
# Or in code
process.env.DEBUG = 'adaptive-tests:*';
Debug categories:
adaptive-tests:discovery
- Discovery engine logsadaptive-tests:cache
- Cache operationsadaptive-tests:ast
- AST parsing detailsadaptive-tests:score
- Scoring algorithm
Getting More Help
-
Check existing issues: GitHub Issues
-
Ask on GitHub: Open a discussion
-
Provide reproduction:
# Create minimal reproduction
npx create-adaptive-repro my-issue
- Include debug info:
npx adaptive-tests debug --system-info > debug.log
When reporting issues, include:
- Adaptive-tests version
- Node.js/Python/Java version
- Operating system
- Error messages
- Minimal code to reproduce
Quick Fixes Checklist
- Is adaptive-tests installed? (
npm list adaptive-tests
) - Are you using the latest version? (
npm update adaptive-tests
) - Is the file path correct? (case-sensitive on Linux)
- Is the export name exact? (case-sensitive)
- Did you clear the cache? (
npx adaptive-tests clear-cache
) - Are all dependencies installed? (
npm ci
) - Is TypeScript configured? (
ts-node
installed?) - Is the signature valid JSON? (
npx adaptive-tests validate
)
Prevention Tips
- Use TypeScript for better IDE support and type checking
- Enable linting to catch issues early
- Add pre-commit hooks for consistency
- Document your patterns for team members
- Keep dependencies updated regularly
- Test on multiple platforms if deploying broadly
- Use the VS Code extension for visual debugging
Remember: Most issues are related to paths, exports, or configuration. When in doubt, use the Discovery Lens (npx adaptive-tests why
) to see what the engine sees!