**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
|
|
|
import { defineConfig } from 'vitest/config'
|
|
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
test: {
|
|
|
|
|
// Default configuration
|
|
|
|
|
globals: true,
|
|
|
|
|
setupFiles: ['./tests/setup.ts'],
|
|
|
|
|
testTimeout: 60000, // 60 seconds for TensorFlow operations
|
|
|
|
|
hookTimeout: 60000,
|
|
|
|
|
// Include test files
|
|
|
|
|
include: ['tests/**/*.{test,spec}.{js,ts}'],
|
2025-07-16 11:40:42 -07:00
|
|
|
// Default environment
|
|
|
|
|
environment: 'node',
|
**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
|
|
|
// Exclude old test files
|
|
|
|
|
exclude: [
|
|
|
|
|
'node_modules/**',
|
|
|
|
|
'dist/**',
|
|
|
|
|
'scripts/**',
|
|
|
|
|
'examples/**',
|
|
|
|
|
'cli-package/**',
|
|
|
|
|
'*.js' // Exclude old JS test files in root
|
|
|
|
|
],
|
|
|
|
|
// Add environment options to help with TextEncoder issues
|
|
|
|
|
environmentOptions: {
|
|
|
|
|
env: {
|
|
|
|
|
FORCE_PATCHED_PLATFORM: 'true'
|
|
|
|
|
}
|
2025-07-16 11:40:42 -07:00
|
|
|
},
|
|
|
|
|
// Reduce noise in output
|
|
|
|
|
silent: false,
|
|
|
|
|
// Configure error display for better readability
|
|
|
|
|
bail: 0,
|
|
|
|
|
// Disable coverage reports by default to reduce noise
|
|
|
|
|
coverage: {
|
|
|
|
|
enabled: false
|
|
|
|
|
},
|
|
|
|
|
// Reduce verbosity of test output
|
|
|
|
|
logHeapUsage: false,
|
|
|
|
|
// Only show failed tests in detail
|
|
|
|
|
hideSkippedTests: true,
|
|
|
|
|
// Reduce stack trace noise
|
|
|
|
|
printConsoleTrace: false,
|
|
|
|
|
// Filter out noisy console output more aggressively
|
|
|
|
|
onConsoleLog: (log: string, type: 'stdout' | 'stderr'): false | void => {
|
|
|
|
|
// Filter out all TensorFlow.js, model loading, and setup noise
|
|
|
|
|
const noisePatterns: string[] = []
|
|
|
|
|
|
|
|
|
|
// Return false (don't show) if log contains any noise pattern
|
|
|
|
|
if (noisePatterns.some((pattern) => log.includes(pattern))) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
**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
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// Resolve configuration for proper module handling
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'@': './src',
|
|
|
|
|
'@tests': './tests'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// Define different configurations for different environments
|
|
|
|
|
define: {
|
|
|
|
|
'process.env.NODE_ENV': '"test"'
|
|
|
|
|
}
|
|
|
|
|
})
|