**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
|
|
|
/**
|
|
|
|
|
* Core Functionality Tests
|
|
|
|
|
* Tests core Brainy features as a consumer would use them
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { describe, it, expect, beforeAll } from 'vitest'
|
|
|
|
|
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
/**
|
|
|
|
|
* Helper function to create a 512-dimensional vector for testing
|
|
|
|
|
* @param primaryIndex The index to set to 1.0, all other indices will be 0.0
|
|
|
|
|
* @returns A 512-dimensional vector with a single 1.0 value at the specified index
|
|
|
|
|
*/
|
|
|
|
|
function createTestVector(primaryIndex: number = 0): number[] {
|
|
|
|
|
const vector = new Array(512).fill(0)
|
|
|
|
|
vector[primaryIndex % 512] = 1.0
|
|
|
|
|
return vector
|
|
|
|
|
}
|
|
|
|
|
|
**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
|
|
|
describe('Brainy Core Functionality', () => {
|
|
|
|
|
let brainy: any
|
|
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
|
// Load brainy library as a consumer would
|
|
|
|
|
brainy = await import('../dist/unified.js')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('Library Exports', () => {
|
|
|
|
|
it('should export BrainyData class', () => {
|
|
|
|
|
expect(brainy.BrainyData).toBeDefined()
|
|
|
|
|
expect(typeof brainy.BrainyData).toBe('function')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('should export environment detection functions', () => {
|
|
|
|
|
expect(typeof brainy.isBrowser).toBe('function')
|
|
|
|
|
expect(typeof brainy.isNode).toBe('function')
|
|
|
|
|
expect(typeof brainy.isWebWorker).toBe('function')
|
|
|
|
|
expect(typeof brainy.areWebWorkersAvailable).toBe('function')
|
|
|
|
|
expect(typeof brainy.isThreadingAvailable).toBe('function')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('should export embedding function creator', () => {
|
|
|
|
|
expect(typeof brainy.createEmbeddingFunction).toBe('function')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('should export environment object', () => {
|
|
|
|
|
expect(brainy.environment).toBeDefined()
|
|
|
|
|
expect(typeof brainy.environment).toBe('object')
|
|
|
|
|
expect(brainy.environment).toHaveProperty('isBrowser')
|
|
|
|
|
expect(brainy.environment).toHaveProperty('isNode')
|
|
|
|
|
expect(brainy.environment).toHaveProperty('isServerless')
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('BrainyData Configuration', () => {
|
|
|
|
|
it('should create instance with minimal configuration', () => {
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
const data = new brainy.BrainyData({})
|
**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
|
|
|
|
|
|
|
|
expect(data).toBeDefined()
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
expect(data.dimensions).toBe(512)
|
**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
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('should create instance with full configuration', () => {
|
|
|
|
|
const data = new brainy.BrainyData({
|
|
|
|
|
metric: 'cosine',
|
|
|
|
|
maxConnections: 32,
|
|
|
|
|
efConstruction: 200,
|
|
|
|
|
storage: 'memory'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
expect(data).toBeDefined()
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
expect(data.dimensions).toBe(512)
|
**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
|
|
|
})
|
|
|
|
|
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
it('should not throw with valid configuration parameters', () => {
|
|
|
|
|
// Dimensions are now fixed at 512 and not configurable
|
**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
|
|
|
expect(() => {
|
|
|
|
|
new brainy.BrainyData({
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
metric: 'cosine'
|
**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
|
|
|
})
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
}).not.toThrow()
|
**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
|
|
|
|
|
|
|
|
expect(() => {
|
|
|
|
|
new brainy.BrainyData({
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
metric: 'euclidean'
|
**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
|
|
|
})
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
}).not.toThrow()
|
**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
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('should use default values for optional parameters', () => {
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
const data = new brainy.BrainyData({})
|
**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
|
|
|
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
expect(data.dimensions).toBe(512)
|
**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
|
|
|
// Should have reasonable defaults for other parameters
|
|
|
|
|
expect(data.maxConnections).toBeGreaterThan(0)
|
|
|
|
|
expect(data.efConstruction).toBeGreaterThan(0)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('Vector Operations', () => {
|
|
|
|
|
it('should handle vector addition and search', async () => {
|
|
|
|
|
const data = new brainy.BrainyData({
|
|
|
|
|
metric: 'euclidean'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
await data.init()
|
2025-07-16 11:39:53 -07:00
|
|
|
await data.clear() // Clear any existing data
|
**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
|
|
|
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
// Add vectors using helper function
|
|
|
|
|
await data.add(createTestVector(0), { id: 'v1', label: 'x-axis' })
|
|
|
|
|
await data.add(createTestVector(1), { id: 'v2', label: 'y-axis' })
|
|
|
|
|
await data.add(createTestVector(2), { id: 'v3', label: 'z-axis' })
|
**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
|
|
|
|
|
|
|
|
// Search for similar vector
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
const results = await data.search(createTestVector(0), 1)
|
**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
|
|
|
|
|
|
|
|
expect(results).toBeDefined()
|
|
|
|
|
expect(results.length).toBe(1)
|
|
|
|
|
expect(results[0].metadata.id).toBe('v1')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('should handle batch vector operations', async () => {
|
|
|
|
|
const data = new brainy.BrainyData({
|
|
|
|
|
metric: 'euclidean'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
await data.init()
|
2025-07-16 11:39:53 -07:00
|
|
|
await data.clear() // Clear any existing data
|
**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
|
|
|
|
|
|
|
|
// Add multiple vectors
|
|
|
|
|
const vectors = [
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
{ vector: createTestVector(10), metadata: { id: 'batch1' } },
|
|
|
|
|
{ vector: createTestVector(20), metadata: { id: 'batch2' } },
|
|
|
|
|
{ vector: createTestVector(30), metadata: { id: 'batch3' } }
|
**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
|
|
|
]
|
|
|
|
|
|
|
|
|
|
for (const { vector, metadata } of vectors) {
|
|
|
|
|
await data.add(vector, metadata)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Search should return results
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
const results = await data.search(createTestVector(15), 3)
|
**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
|
|
|
expect(results.length).toBe(3)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('should handle different distance metrics', async () => {
|
|
|
|
|
const euclideanData = new brainy.BrainyData({
|
|
|
|
|
metric: 'euclidean'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const cosineData = new brainy.BrainyData({
|
|
|
|
|
metric: 'cosine'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
await euclideanData.init()
|
|
|
|
|
await cosineData.init()
|
2025-07-16 13:08:41 -07:00
|
|
|
|
2025-07-16 11:39:53 -07:00
|
|
|
// Clear any existing data to ensure test isolation
|
|
|
|
|
await euclideanData.clear()
|
|
|
|
|
await cosineData.clear()
|
**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
|
|
|
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
const vector = createTestVector(5)
|
**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
|
|
|
const metadata = { id: 'test' }
|
|
|
|
|
|
|
|
|
|
await euclideanData.add(vector, metadata)
|
|
|
|
|
await cosineData.add(vector, metadata)
|
|
|
|
|
|
|
|
|
|
const euclideanResults = await euclideanData.search(vector, 1)
|
|
|
|
|
const cosineResults = await cosineData.search(vector, 1)
|
|
|
|
|
|
|
|
|
|
expect(euclideanResults.length).toBe(1)
|
|
|
|
|
expect(cosineResults.length).toBe(1)
|
|
|
|
|
|
|
|
|
|
// Both should find the exact match, but distances might differ
|
|
|
|
|
expect(euclideanResults[0].metadata.id).toBe('test')
|
|
|
|
|
expect(cosineResults[0].metadata.id).toBe('test')
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('Text Processing', () => {
|
2025-07-16 11:39:53 -07:00
|
|
|
it(
|
|
|
|
|
'should handle text items with embedding function',
|
|
|
|
|
async () => {
|
|
|
|
|
const embeddingFunction = brainy.createEmbeddingFunction()
|
|
|
|
|
|
|
|
|
|
const data = new brainy.BrainyData({
|
|
|
|
|
embeddingFunction,
|
|
|
|
|
dimensions: 512, // Universal Sentence Encoder produces 512-dimensional vectors
|
2025-07-17 10:00:28 -07:00
|
|
|
metric: 'cosine',
|
|
|
|
|
storage: {
|
|
|
|
|
forceMemoryStorage: true
|
|
|
|
|
}
|
2025-07-16 11:39:53 -07:00
|
|
|
})
|
**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
|
|
|
|
2025-07-16 11:39:53 -07:00
|
|
|
await data.init()
|
**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
|
|
|
|
2025-07-16 11:39:53 -07:00
|
|
|
// Add text items
|
|
|
|
|
await data.addItem('Hello world', { id: 'greeting', type: 'text' })
|
|
|
|
|
await data.addItem('Goodbye world', { id: 'farewell', type: 'text' })
|
**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
|
|
|
|
2025-07-16 11:39:53 -07:00
|
|
|
// Search with text
|
|
|
|
|
const results = await data.search('Hi there', 1)
|
**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
|
|
|
|
2025-07-16 11:39:53 -07:00
|
|
|
expect(results).toBeDefined()
|
|
|
|
|
expect(results.length).toBeGreaterThan(0)
|
|
|
|
|
expect(results[0].metadata).toHaveProperty('id')
|
|
|
|
|
},
|
|
|
|
|
globalThis.testUtils?.timeout || 30000
|
|
|
|
|
)
|
**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
|
|
|
|
2025-07-16 11:39:53 -07:00
|
|
|
it(
|
|
|
|
|
'should handle mixed vector and text operations',
|
|
|
|
|
async () => {
|
|
|
|
|
const embeddingFunction = brainy.createEmbeddingFunction()
|
**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
|
|
|
|
2025-07-16 11:39:53 -07:00
|
|
|
const data = new brainy.BrainyData({
|
|
|
|
|
embeddingFunction,
|
|
|
|
|
dimensions: 512, // Universal Sentence Encoder produces 512-dimensional vectors
|
|
|
|
|
metric: 'cosine'
|
|
|
|
|
})
|
**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
|
|
|
|
2025-07-16 11:39:53 -07:00
|
|
|
await data.init()
|
**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
|
|
|
|
2025-07-16 11:39:53 -07:00
|
|
|
// Add text item
|
|
|
|
|
await data.addItem('Machine learning', { id: 'text1', type: 'text' })
|
**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
|
|
|
|
2025-07-16 11:39:53 -07:00
|
|
|
// Add vector item (using embedding of similar text)
|
|
|
|
|
const embedding = await embeddingFunction('Artificial intelligence')
|
|
|
|
|
await data.add(embedding, { id: 'vector1', type: 'vector' })
|
**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
|
|
|
|
2025-07-16 11:39:53 -07:00
|
|
|
// Search should find both
|
|
|
|
|
const results = await data.search('AI and ML', 2)
|
**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
|
|
|
|
2025-07-16 11:39:53 -07:00
|
|
|
expect(results).toBeDefined()
|
|
|
|
|
expect(results.length).toBeGreaterThan(0)
|
|
|
|
|
},
|
|
|
|
|
globalThis.testUtils?.timeout || 30000
|
|
|
|
|
)
|
**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
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('Error Handling', () => {
|
|
|
|
|
it('should handle invalid vector dimensions', async () => {
|
|
|
|
|
const data = new brainy.BrainyData({
|
|
|
|
|
metric: 'euclidean'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
await data.init()
|
|
|
|
|
|
|
|
|
|
// Try to add vector with wrong dimensions
|
|
|
|
|
await expect(data.add([1, 2], { id: 'wrong' })).rejects.toThrow()
|
2025-08-01 18:31:37 -07:00
|
|
|
await expect(
|
|
|
|
|
data.add(new Array(100).fill(0), { id: 'wrong' })
|
|
|
|
|
).rejects.toThrow()
|
**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
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('should handle search before initialization', async () => {
|
|
|
|
|
const data = new brainy.BrainyData({
|
|
|
|
|
metric: 'euclidean'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Try to search without initialization
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
await expect(data.search(createTestVector(0), 1)).rejects.toThrow()
|
**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
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('should handle empty search results gracefully', async () => {
|
|
|
|
|
const data = new brainy.BrainyData({
|
|
|
|
|
metric: 'euclidean'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
await data.init()
|
2025-07-16 11:39:53 -07:00
|
|
|
await data.clear() // Clear any existing data
|
**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
|
|
|
|
|
|
|
|
// Search in empty database
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
const results = await data.search(createTestVector(0), 1)
|
**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
|
|
|
expect(results).toBeDefined()
|
|
|
|
|
expect(Array.isArray(results)).toBe(true)
|
|
|
|
|
expect(results.length).toBe(0)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('Performance and Scalability', () => {
|
|
|
|
|
it('should handle moderate number of vectors efficiently', async () => {
|
|
|
|
|
const data = new brainy.BrainyData({
|
|
|
|
|
metric: 'euclidean'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
await data.init()
|
|
|
|
|
|
|
|
|
|
const startTime = Date.now()
|
|
|
|
|
|
|
|
|
|
// Add 100 test vectors
|
|
|
|
|
for (let i = 0; i < 100; i++) {
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
await data.add(createTestVector(i), { id: `item_${i}`, index: i })
|
**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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const addTime = Date.now() - startTime
|
|
|
|
|
|
|
|
|
|
// Search should be fast
|
|
|
|
|
const searchStart = Date.now()
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
const results = await data.search(createTestVector(50), 10)
|
**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
|
|
|
const searchTime = Date.now() - searchStart
|
|
|
|
|
|
|
|
|
|
expect(results.length).toBeLessThanOrEqual(10)
|
|
|
|
|
expect(addTime).toBeLessThan(10000) // Should complete within 10 seconds
|
|
|
|
|
expect(searchTime).toBeLessThan(1000) // Search should be under 1 second
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('should maintain search quality with more data', async () => {
|
2025-07-16 13:08:41 -07:00
|
|
|
// Create database with proper configuration for testing
|
|
|
|
|
const db = new brainy.BrainyData({
|
|
|
|
|
embeddingFunction: brainy.createEmbeddingFunction(),
|
|
|
|
|
metric: 'cosine'
|
**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
|
|
|
})
|
|
|
|
|
|
2025-07-16 13:08:41 -07:00
|
|
|
await db.init()
|
|
|
|
|
await db.clear() // Clear any existing data
|
**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
|
|
|
|
2025-07-16 13:08:41 -07:00
|
|
|
// Add known data
|
|
|
|
|
await db.add('known data', { id: 'known' })
|
**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
|
|
|
|
2025-07-16 13:08:41 -07:00
|
|
|
// Add noise data
|
|
|
|
|
for (let i = 0; i < 100; i++) {
|
|
|
|
|
await db.add(`noise_${i}`, { id: `noise_${i}` })
|
**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
|
|
|
}
|
|
|
|
|
|
2025-07-16 13:08:41 -07:00
|
|
|
// Perform search using the correct method
|
|
|
|
|
const results = await db.search('known data', 10)
|
|
|
|
|
|
|
|
|
|
// Debugging output
|
|
|
|
|
console.log(
|
|
|
|
|
'Search results:',
|
|
|
|
|
results.map((r) => r.metadata?.id)
|
|
|
|
|
)
|
**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
|
|
|
|
2025-07-16 13:08:41 -07:00
|
|
|
// Assertions
|
**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
|
|
|
expect(results.length).toBeGreaterThan(0)
|
2025-08-01 18:31:37 -07:00
|
|
|
// The 'known' item should be found in the results, but not necessarily first
|
|
|
|
|
// due to potential variations in embedding similarity calculations
|
|
|
|
|
const knownItemFound = results.some((r) => r.metadata?.id === 'known')
|
|
|
|
|
expect(knownItemFound).toBe(true)
|
**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
|
|
|
})
|
|
|
|
|
})
|
feat(core, tests): add standalone getStatistics function and improve storage configuration
- **Core**: Introduced a new `getStatistics` utility function in `statistics.ts` for fetching database statistics at the root level of the library. Enhanced `BrainyData` methods to ensure metadata includes `id` field and refined statistics calculations, excluding verbs from the noun count.
- **Tests**: Added comprehensive test coverage in `statistics.test.ts` for the new utility function, validating proper error handling, statistics accuracy, and consistent results between instance methods and standalone function.
- **Storage Config**: Enabled dynamic support for AWS S3, Cloudflare R2, and Google Cloud Storage in web service configuration, utilizing environment variables for adapter setup. Addressed a race condition in `FileSystemStorage` initialization by deferring path module imports.
**Purpose**: Enhance database analytics by introducing a reusable `getStatistics` function, improve flexibility in storage configuration, and ensure robust testing for reliability and accuracy.
2025-07-23 16:26:59 -07:00
|
|
|
|
|
|
|
|
describe('Database Statistics', () => {
|
|
|
|
|
it('should provide accurate statistics about the database', async () => {
|
|
|
|
|
const data = new brainy.BrainyData({
|
|
|
|
|
metric: 'euclidean'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
await data.init()
|
|
|
|
|
await data.clear() // Clear any existing data
|
|
|
|
|
|
|
|
|
|
// Add some vectors (nouns)
|
**feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
- Added `check-database.js` to verify database status and validate search functionality.
- Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
- Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.
- **Migration**:
- Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
- Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.
- **Tests**:
- Enhanced test coverage with 512-dimensional vector validation.
- Introduced helper functions for consistent vector testing behavior and streamlined search test cases.
- **Documentation**:
- Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.
**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
|
|
|
await data.add(createTestVector(0), { id: 'v1', label: 'x-axis' })
|
|
|
|
|
await data.add(createTestVector(1), { id: 'v2', label: 'y-axis' })
|
|
|
|
|
await data.add(createTestVector(2), { id: 'v3', label: 'z-axis' })
|
feat(core, tests): add standalone getStatistics function and improve storage configuration
- **Core**: Introduced a new `getStatistics` utility function in `statistics.ts` for fetching database statistics at the root level of the library. Enhanced `BrainyData` methods to ensure metadata includes `id` field and refined statistics calculations, excluding verbs from the noun count.
- **Tests**: Added comprehensive test coverage in `statistics.test.ts` for the new utility function, validating proper error handling, statistics accuracy, and consistent results between instance methods and standalone function.
- **Storage Config**: Enabled dynamic support for AWS S3, Cloudflare R2, and Google Cloud Storage in web service configuration, utilizing environment variables for adapter setup. Addressed a race condition in `FileSystemStorage` initialization by deferring path module imports.
**Purpose**: Enhance database analytics by introducing a reusable `getStatistics` function, improve flexibility in storage configuration, and ensure robust testing for reliability and accuracy.
2025-07-23 16:26:59 -07:00
|
|
|
|
|
|
|
|
// Add some connections (verbs)
|
|
|
|
|
await data.connect('v1', 'v2', 'related_to')
|
|
|
|
|
await data.connect('v2', 'v3', 'related_to')
|
|
|
|
|
|
|
|
|
|
// Get statistics
|
|
|
|
|
const stats = await data.getStatistics()
|
|
|
|
|
|
|
|
|
|
// Debug: Log all nouns in the database
|
|
|
|
|
const allNouns = await data.getAllNouns()
|
2025-08-01 18:31:37 -07:00
|
|
|
console.log(
|
|
|
|
|
'All nouns in database:',
|
|
|
|
|
allNouns.map((n) => n.id)
|
|
|
|
|
)
|
|
|
|
|
|
feat(core, tests): add standalone getStatistics function and improve storage configuration
- **Core**: Introduced a new `getStatistics` utility function in `statistics.ts` for fetching database statistics at the root level of the library. Enhanced `BrainyData` methods to ensure metadata includes `id` field and refined statistics calculations, excluding verbs from the noun count.
- **Tests**: Added comprehensive test coverage in `statistics.test.ts` for the new utility function, validating proper error handling, statistics accuracy, and consistent results between instance methods and standalone function.
- **Storage Config**: Enabled dynamic support for AWS S3, Cloudflare R2, and Google Cloud Storage in web service configuration, utilizing environment variables for adapter setup. Addressed a race condition in `FileSystemStorage` initialization by deferring path module imports.
**Purpose**: Enhance database analytics by introducing a reusable `getStatistics` function, improve flexibility in storage configuration, and ensure robust testing for reliability and accuracy.
2025-07-23 16:26:59 -07:00
|
|
|
// Debug: Log all verbs in the database
|
|
|
|
|
const allVerbs = await data.getAllVerbs()
|
2025-08-01 18:31:37 -07:00
|
|
|
console.log(
|
|
|
|
|
'All verbs in database:',
|
|
|
|
|
allVerbs.map((v) => v.id)
|
|
|
|
|
)
|
|
|
|
|
|
feat(core, tests): add standalone getStatistics function and improve storage configuration
- **Core**: Introduced a new `getStatistics` utility function in `statistics.ts` for fetching database statistics at the root level of the library. Enhanced `BrainyData` methods to ensure metadata includes `id` field and refined statistics calculations, excluding verbs from the noun count.
- **Tests**: Added comprehensive test coverage in `statistics.test.ts` for the new utility function, validating proper error handling, statistics accuracy, and consistent results between instance methods and standalone function.
- **Storage Config**: Enabled dynamic support for AWS S3, Cloudflare R2, and Google Cloud Storage in web service configuration, utilizing environment variables for adapter setup. Addressed a race condition in `FileSystemStorage` initialization by deferring path module imports.
**Purpose**: Enhance database analytics by introducing a reusable `getStatistics` function, improve flexibility in storage configuration, and ensure robust testing for reliability and accuracy.
2025-07-23 16:26:59 -07:00
|
|
|
// Debug: Log the verb IDs set used in getStatistics
|
2025-08-01 18:31:37 -07:00
|
|
|
const verbIds = new Set(allVerbs.map((verb) => verb.id))
|
feat(core, tests): add standalone getStatistics function and improve storage configuration
- **Core**: Introduced a new `getStatistics` utility function in `statistics.ts` for fetching database statistics at the root level of the library. Enhanced `BrainyData` methods to ensure metadata includes `id` field and refined statistics calculations, excluding verbs from the noun count.
- **Tests**: Added comprehensive test coverage in `statistics.test.ts` for the new utility function, validating proper error handling, statistics accuracy, and consistent results between instance methods and standalone function.
- **Storage Config**: Enabled dynamic support for AWS S3, Cloudflare R2, and Google Cloud Storage in web service configuration, utilizing environment variables for adapter setup. Addressed a race condition in `FileSystemStorage` initialization by deferring path module imports.
**Purpose**: Enhance database analytics by introducing a reusable `getStatistics` function, improve flexibility in storage configuration, and ensure robust testing for reliability and accuracy.
2025-07-23 16:26:59 -07:00
|
|
|
console.log('Verb IDs set:', Array.from(verbIds))
|
|
|
|
|
|
|
|
|
|
// Verify statistics
|
|
|
|
|
expect(stats).toBeDefined()
|
|
|
|
|
expect(stats).toHaveProperty('nounCount')
|
|
|
|
|
expect(stats).toHaveProperty('verbCount')
|
|
|
|
|
expect(stats).toHaveProperty('metadataCount')
|
|
|
|
|
expect(stats).toHaveProperty('hnswIndexSize')
|
|
|
|
|
|
|
|
|
|
// Verify counts
|
|
|
|
|
expect(stats.nounCount).toBe(3)
|
|
|
|
|
expect(stats.verbCount).toBe(2)
|
2025-07-31 13:40:28 -07:00
|
|
|
expect(stats.hnswIndexSize).toBe(1)
|
feat(core, tests): add standalone getStatistics function and improve storage configuration
- **Core**: Introduced a new `getStatistics` utility function in `statistics.ts` for fetching database statistics at the root level of the library. Enhanced `BrainyData` methods to ensure metadata includes `id` field and refined statistics calculations, excluding verbs from the noun count.
- **Tests**: Added comprehensive test coverage in `statistics.test.ts` for the new utility function, validating proper error handling, statistics accuracy, and consistent results between instance methods and standalone function.
- **Storage Config**: Enabled dynamic support for AWS S3, Cloudflare R2, and Google Cloud Storage in web service configuration, utilizing environment variables for adapter setup. Addressed a race condition in `FileSystemStorage` initialization by deferring path module imports.
**Purpose**: Enhance database analytics by introducing a reusable `getStatistics` function, improve flexibility in storage configuration, and ensure robust testing for reliability and accuracy.
2025-07-23 16:26:59 -07:00
|
|
|
})
|
|
|
|
|
})
|
**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
|
|
|
})
|