How unit tests and integration tests differ
mainThe project uses two distinct testing layers to balance speed and reliability:
Unit Tests (src/__tests__/)
- Framework: Vitest
- Purpose: Testing single functions or classes in isolation with mocked dependencies.
- Characteristics: Fast (milliseconds), runs automatically in CI/CD, provides coverage reporting.
- Execution:
npm test
Integration & Manual Tests (tests/)
- Framework: Custom Node.js scripts
- Purpose: Testing multiple components together, full workflows, and manual debugging.
- Characteristics: Slower (seconds), uses real file systems and databases, requires manual verification.
- Execution:
npm run test:integrationornode tests/test-*.js
// Example Unit Test (src/__tests__/sqlite-db.test.ts)
it('should store semantic concepts', () => {
const concept = { id: 'test', name: 'TestClass', ... };
database.insertSemanticConcept(concept);
expect(database.getSemanticConcepts()).toHaveLength(1);
});
// Example Integration Test (tests/test-learning.js)
const analyzer = new SemanticAnalyzer();
const concepts = await analyzer.learnFromCodebase("./src");
console.log(`Learned ${concepts.length} concepts`);