#!/usr/bin/env node
/**
* Script to run the Keet messaging test.
*/
import { testKeetMessaging } from './keet_messaging_test.js';
// Configure logging
const logLevels = {
INFO: 'INFO',
ERROR: 'ERROR',
WARNING: 'WARNING'
};
function log(level, message) {
const timestamp = new Date().toISOString();
console.log(`[${timestamp}] [${level}] ${message}`);
}
async function runTests() {
log(logLevels.INFO, '=== Running Keet Messaging Test ===');
// Run the real test
const success = await testKeetMessaging();
if (success) {
log(logLevels.INFO, 'Keet messaging test completed successfully');
} else {
log(logLevels.WARNING, 'Keet messaging test was skipped or failed');
}
// Return overall success
return success;
}
// Run the tests if this file is executed directly
if (import.meta.url === `file://${process.argv[1]}`) {
try {
const success = await runTests();
if (success) {
log(logLevels.INFO, 'All tests completed successfully');
process.exit(0);
} else {
log(logLevels.ERROR, 'Some tests failed');
process.exit(1);
}
} catch (error) {
log(logLevels.ERROR, `Unhandled error: ${error.message}`);
log(logLevels.ERROR, error.stack);
process.exit(1);
}
}
export { runTests };