- **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.
24 lines
757 B
JavaScript
24 lines
757 B
JavaScript
const { applyTensorFlowPatch } = require('./src/utils/textEncoding.js')
|
|
|
|
console.log('Before patch:')
|
|
console.log('global.TextEncoder:', typeof global.TextEncoder)
|
|
console.log('global.__TextEncoder__:', typeof global.__TextEncoder__)
|
|
|
|
applyTensorFlowPatch()
|
|
|
|
console.log('After patch:')
|
|
console.log('global.TextEncoder:', typeof global.TextEncoder)
|
|
console.log('global.__TextEncoder__:', typeof global.__TextEncoder__)
|
|
|
|
// Try to import tensorflow
|
|
async function testTensorFlow() {
|
|
try {
|
|
console.log('Importing TensorFlow...')
|
|
const tf = await import('@tensorflow/tfjs-core')
|
|
console.log('TensorFlow imported successfully:', tf.version)
|
|
} catch (error) {
|
|
console.error('TensorFlow import failed:', error.message)
|
|
}
|
|
}
|
|
|
|
testTensorFlow()
|