**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

34
fix-documentation.md Normal file
View file

@ -0,0 +1,34 @@
# Fix for "process.memoryUsage is not a function" Error
## Issue
During test runs with Vitest, the following error was occurring:
```
TypeError: process.memoryUsage is not a function
VitestTestRunner.onAfterRunSuite node_modules/vitest/dist/runners.js:150:95
```
This error was happening because Vitest was trying to use `process.memoryUsage()` to log heap usage statistics, but this function was not available in the current environment.
## Solution
The issue was fixed by disabling the heap usage logging in the Vitest configuration:
In `vitest.config.ts`, changed:
```typescript
// Show test statistics
logHeapUsage: true,
```
To:
```typescript
// Show test statistics
logHeapUsage: false,
```
## Explanation
The `logHeapUsage` option in Vitest attempts to use Node.js's `process.memoryUsage()` function to track and report memory usage during test runs. However, this function might not be available in all environments, particularly in certain browser-like environments or when using specific Node.js versions or configurations.
By setting `logHeapUsage: false`, we prevent Vitest from attempting to call this function, which resolves the error while still allowing tests to run successfully.
## Verification
After making this change, the tests run without any unhandled errors, confirming that the issue has been resolved.