veriqa-test-advisor
Version:
AI-powered regression test case advisor CLI tool with integrated Manual QA support
63 lines (49 loc) โข 2.1 kB
JavaScript
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();