test.jsโข1.96 kB
#!/usr/bin/env node
/**
* Test script for the Dad Joke Visualizer MCP Server
* This script tests the individual components without running the full MCP server
*/
import dotenv from 'dotenv';
import { generateDadJoke } from './dist/tools/jokeGenerator.js';
import { generateImage } from './dist/tools/imageGenerator.js';
import { createWebPage, startWebServer } from './dist/tools/webPageCreator.js';
dotenv.config();
async function testComponents() {
console.log('๐งช Testing Dad Joke Visualizer Components...\n');
try {
// Test 1: Generate a Dad Joke (now built-in, no API key needed!)
console.log('1๏ธโฃ Testing Built-in Dad Joke Generation...');
const joke = await generateDadJoke('programming');
console.log(`โ
Generated joke: "${joke}"\n`);
// Test 2: Generate Image (will use fallback placeholder if API key not available)
console.log('2๏ธโฃ Testing Image Generation...');
const imageUrl = await generateImage(joke);
console.log(`โ
Generated image URL: ${imageUrl}\n`);
// Test 3: Start Web Server
console.log('3๏ธโฃ Testing Web Server...');
await startWebServer();
console.log('โ
Web server started successfully\n');
// Test 4: Create Web Page
console.log('4๏ธโฃ Testing Web Page Creation...');
const pageUrl = await createWebPage(joke, imageUrl);
console.log(`โ
Created web page: ${pageUrl}\n`);
console.log('๐ All tests passed! Your Dad Joke Visualizer is ready to use.');
console.log(`\n๐ Visit the web interface at: http://localhost:${process.env.PORT || 3000}`);
console.log(`๐ View your test joke at: ${pageUrl}`);
console.log('\n๐ญ Note: No external API keys required! Dad jokes are built-in! ๐ช');
} catch (error) {
console.error('โ Test failed:', error);
process.exit(1);
}
}
// Run tests if this script is executed directly
if (import.meta.url === `file://${process.argv[1]}`) {
testComponents();
}