Commit graph

8 commits

Author SHA1 Message Date
6e85468879 fix: optimize package size and improve test reliability
Major improvements to build process, package optimization, and test infrastructure:

## Package Size Optimization (3.4MB → 2.2MB)
- Remove source maps from npm package (reduce size by 35%)
- Update package.json files field to exclude *.js.map and *.d.ts.map
- Enhanced .npmignore for better exclusion patterns
- Preserve all browser compatibility and universal shims

## Test Infrastructure Fixes
- Increase test timeouts to 120s for TensorFlow operations
- Improve memory management with garbage collection hooks
- Add proper cleanup between tests to prevent file accumulation
- Configure single-fork test execution to reduce memory usage
- Fix test parameter issues in intelligent verb scoring tests

## Bug Fixes
- Fix lock directory creation in FileSystemStorage
- Remove deprecated node-fetch import from api-integration tests
- Fix addVerb() and db.add() parameter usage throughout test suite
- Ensure proper vector dimensions (384) in all test vectors
- Add directory existence checks before lock file operations

## Build & Development
- Update vitest configuration for better concurrency and reliability
- Add comprehensive test cleanup in setup.ts
- Preserve all browser JavaScript functionality and universal compatibility layer

The package now meets size requirements while maintaining full functionality
for both browser and Node.js environments.
2025-08-10 13:52:01 -07:00
60d3a74ea1 **chore: remove unused CLI package references and update gitignore**
- **Codebase Cleanup**:
  - Removed `cli-package/**` from Vitest configuration exclude paths.
  - Updated `.gitignore` by removing entries related to `cli-package` and its subdirectories.

- **Purpose**:
  - Simplify the repository and reduce clutter by eliminating obsolete references to the removed CLI package.
2025-08-02 17:23:03 -07:00
a6eeba23da **build: update test results configuration and gitignore**
- Updated test results output path in `vitest.config.ts` to `./tests/results/test-results.json` for better organization.
- Modified `.gitignore` to include `/tests/results/` and its `.json` files to avoid committing test artifacts.

**Purpose**: Improves test results file structure and ensures consistent exclusion of test artifact files from version control.
2025-07-30 10:42:18 -07:00
94c88e128c **docs: remove outdated statistics-related documentation and add standards**
- **Removed Files**:
  - Deleted outdated statistics documentation files (`statistics.md`, `statistics-flush-solution.md`, `statistics-summary.md`) to clean up the repository and avoid confusion.

- **Added Standards**:
  - Introduced `DOCUMENTATION_STANDARDS.md` to outline naming conventions and troubleshooting practices for more consistent and maintainable project documentation.

- **Tests**:
  - Added a new test file `edge-cases.test.ts` to verify handling of edge cases, ensuring robust behavior against boundary values and invalid inputs.

**Purpose**: Cleans up deprecated documentation while introducing concrete standards for maintaining and updating documentation. Enhances test coverage for unusual or boundary inputs, improving overall system resilience.
2025-07-28 16:00:05 -07:00
7f082df6a3 **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.
2025-07-28 10:04:45 -07:00
ad4af27385 **test(tests): improve isolation and enhance test configuration**
- **Test Enhancements**:
  - Refactored test setup in `core.test.ts` for better isolation and clarity:
    - Added explicit `.clear()` calls to ensure clean state between tests.
    - Replaced old vector addition logic with simplified data insertion methods.
    - Updated search operations to reflect current functionality and debug-friendly output.
  - Introduced the `@vitest-environment jsdom` annotation in `environment.browser.test.ts` for accurate browser environment emulation.

- **Configuration Updates**:
  - Enhanced `vitest.config.ts`:
    - Introduced custom `reporters` for cleaner and focused test result presentation.
    - Expanded console log filtering with additional patterns for reducing noise from TensorFlow.js and setup processes.

- **Purpose**:
  - These updates improve test clarity, consistency, and robustness while streamlining the configuration to minimize distractions in test outputs.
2025-07-16 13:08:41 -07:00
238831af23 **test(vitest): enhance test config with environment defaults and improved readability**
- **Configuration Updates**:
  - Set default test environment to `node` for consistency.
  - Reduced noise in test outputs by configuring options such as `silent`, `bail`, `hideSkippedTests`, `printConsoleTrace`, and `onConsoleLog`.
  - Disabled test coverage reports by default for reduced verbosity.
  - Added functionality to filter out noisy console logs more aggressively.

- **Purpose**:
  - Improves the clarity and readability of test output, reduces unnecessary verbosity, and ensures consistent behavior in a `node` environment. Encourages focus on debugging failed tests by hiding irrelevant details.
2025-07-16 11:40:42 -07:00
8ffc7115a5 **test(tests): add comprehensive test suite for Brainy functionality**
- **New Tests Added**:
  - Introduced multiple test suites covering core functionalities (`core.test.ts`), vector operations (`vector-operations.test.ts`), Node.js environment (`environment.node.test.ts`), browser setup (`environment.browser.test.ts`), and TensorFlow.js-specific behaviors (`tensorflow-patch.test.ts`).
  - Added performance, scalability, and error-handling tests to ensure robust validation of vector addition, search, and text embedding functionalities.
  - Introduced setup utilities (`tests/setup.ts`) and standardized test utilities for creating predictable test cases.

- **Configuration**:
  - Created `vitest.config.ts` for custom test configurations, including support for modern test environments (`jsdom`, `happy-dom`) and extended timeouts for asynchronous operations.

- **Validation**:
  - Includes compatibility checks for TensorFlow.js imports and ensures proper handling of `TextEncoder`/`TextDecoder` in Node.js environments.

This commit significantly enhances the testing coverage and structure, ensuring Brainy functionality is robust, cross-platform, and aligned with evolving reliability standards.
2025-07-15 11:56:16 -07:00