**refactor(tests): consolidate and replace outdated environment test scripts**

- Removed obsolete scripts: `test-all-environments.js`, `test-fallback-function.js`, `test-fallback-simple.js`, `test-fix.js`, `test-tensorflow-textencoder.js`, `test-unified-encoding.js`, and `test-worker-utils.js`.
- Introduced `scripts/comprehensive-test.js` as a unified testing script covering all environments: Browser, Node.js, and CLI.
- Added `examples/cli-wrapper-example.js` to demonstrate a proper CLI implementation with TensorFlow.js initialization.

This refactor simplifies the testing structure by consolidating redundant scripts into a single comprehensive script while ensuring robust cross-environment coverage.
This commit is contained in:
David Snelling 2025-07-14 11:12:51 -07:00
parent 3b85ea46e1
commit f5e4b8b93e
20 changed files with 1253 additions and 808 deletions

View file

@ -1,47 +0,0 @@
// Test script to verify the TextEncoder fix
import { applyTensorFlowPatch } from './dist/utils/textEncoding.js'
console.log('Testing TextEncoder fix...')
// Apply the TensorFlow.js platform patch
applyTensorFlowPatch()
// Check if PlatformNode is defined in the global object
if (typeof global.PlatformNode === 'function') {
console.log('PlatformNode is defined in the global object')
// Create an instance of PlatformNode
try {
const platform = new global.PlatformNode()
console.log('Successfully created PlatformNode instance')
// Check if textEncoder is defined
if (platform.textEncoder) {
console.log('textEncoder is defined')
// Test encoding a string
const testString = 'Hello, world! 👋'
const encoded = platform.textEncoder.encode(testString)
console.log(`Successfully encoded string: ${testString}`)
console.log(`Encoded: [${encoded}]`)
// Test decoding
const decoded = platform.textDecoder.decode(encoded)
console.log(`Successfully decoded back to: ${decoded}`)
if (testString === decoded) {
console.log('✅ TextEncoder/TextDecoder test passed!')
} else {
console.error('❌ TextEncoder/TextDecoder test failed!')
}
} else {
console.error('textEncoder is not defined in the platform instance')
}
} catch (error) {
console.error('Error creating PlatformNode instance:', error)
}
} else {
console.error('PlatformNode is not defined in the global object')
}
console.log('Test completed')