UNPKG

veriqa-test-advisor

Version:

AI-powered regression test case advisor CLI tool with integrated Manual QA support

63 lines (49 loc) โ€ข 2.1 kB
#!/usr/bin/env node const chalk = require('chalk'); require('dotenv').config(); console.log(chalk.blue('๐Ÿงช Quick Gemini API Test')); const geminiKey = process.env.GEMINI_API_KEY; if (!geminiKey || geminiKey.includes('your_')) { console.log(chalk.red('โŒ No real Gemini API key found')); console.log(chalk.yellow('๐Ÿ’ก Add your key to .env file: GEMINI_API_KEY=your_actual_key')); process.exit(1); } console.log(chalk.green('โœ… Gemini API key found')); console.log(chalk.dim(`๐Ÿ”‘ Key: ${geminiKey.substring(0, 10)}...${geminiKey.substring(geminiKey.length - 5)}`)); // Simple API test const axios = require('axios'); async function testGemini() { try { const endpoint = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=${geminiKey}`; const payload = { contents: [{ parts: [{ text: "Write a simple JavaScript test for a login function. Keep it short." }] }] }; console.log(chalk.cyan('๐Ÿ”— Calling Gemini API...')); const response = await axios.post(endpoint, payload, { headers: { 'Content-Type': 'application/json' }, timeout: 10000 }); if (response.data && response.data.candidates && response.data.candidates[0]) { const content = response.data.candidates[0].content.parts[0].text; console.log(chalk.green('โœ… Gemini API call successful!')); console.log(chalk.blue('\n๐Ÿ“ AI Response:')); console.log(chalk.dim(content.substring(0, 200) + (content.length > 200 ? '...' : ''))); console.log(chalk.green('\n๐ŸŽ‰ Real AI integration working perfectly!')); } else { console.log(chalk.yellow('โš ๏ธ Unexpected response format')); console.log(response.data); } } catch (error) { if (error.response) { console.log(chalk.red(`โŒ API Error: ${error.response.status}`)); console.log(chalk.red(`Error: ${error.response.data?.error?.message || 'Unknown error'}`)); } else { console.log(chalk.red(`โŒ Network Error: ${error.message}`)); } } } testGemini();