**test(api): add integration tests for API endpoints and core functionality**

- **Integration Tests**:
  - Introduced `api-integration.test.ts` to validate API functionality:
    - Verifies text insertion, vector embedding generation, and search operations.
    - Confirms HNSW index correctness for vector similarity search.
    - Ensures no dimensional mismatches in embeddings.

- **Test Server**:
  - Added test server utilizing Express for endpoint simulation (`/insert` and `/search/text`).

- **Dependencies**:
  - Introduced `express` and `node-fetch` as new dependencies for testing purposes.

- **Vitest Fix**:
  - Updated `vitest.config.ts` to resolve the `process.memoryUsage` error by setting `logHeapUsage: false`.

- **Package Updates**:
  - Modified `package-lock.json` to include newly added dependencies and updates.

**Purpose**: Guarantees the stability of core API endpoints and vector-related functionality, ensuring reliable behavior for end-to-end scenarios.
This commit is contained in:
David Snelling 2025-07-28 10:04:45 -07:00
parent 5d607068a8
commit 7f082df6a3
11 changed files with 1418 additions and 85 deletions

View file

@ -62,6 +62,34 @@ Brainy uses a modern build system that optimizes for both Node.js and browser en
## Testing
### Test Scripts
Brainy provides several test scripts for different testing scenarios:
```bash
# Run all tests
npm test
# Run tests with comprehensive reporting
npm run test:report
# Run tests in watch mode
npm test:watch
# Run tests with UI
npm test:ui
# Run specific test suites
npm run test:node
npm run test:browser
npm run test:core
# Run tests with coverage
npm run test:coverage
```
The `test:report` script provides a comprehensive test report showing detailed information about all tests that were run, including test names, execution time, and pass/fail status.
### Testing Best Practices
When developing and debugging Brainy, follow these testing guidelines:
@ -87,6 +115,11 @@ When developing and debugging Brainy, follow these testing guidelines:
5. **Cleanup**: Always clean up temporary files before committing. The vitest configuration already excludes `*.js` files in the root directory, but they should be deleted rather than left in the repository.
6. **Test Reporting**: Use the comprehensive test reporting feature when you need detailed information about test execution:
- Run `npm run test:report` to get a verbose report of all tests
- The report includes test names, execution time, and pass/fail status
- This is especially useful for CI/CD pipelines and debugging test failures
### Testing All Environments
Brainy provides a comprehensive test script that verifies the library works correctly in all supported environments (