@future-agi/ai-evaluation
Version:
We help GenAI teams maintain high-accuracy for their Models in production.
69 lines • 3.48 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { Evaluator } from '../evaluator';
// Helper to conditionally run tests only if environment variables are set
const describeIf = (condition, ...args) => condition ? describe(...args) : describe.skip(...args);
const hasIntegrationEnv = !!(process.env.FI_API_KEY && process.env.FI_SECRET_KEY && process.env.FI_BASE_URL);
describeIf(hasIntegrationEnv, 'API Health Check', () => {
let evaluator;
beforeAll(() => {
evaluator = new Evaluator({
fiApiKey: process.env.FI_API_KEY,
fiSecretKey: process.env.FI_SECRET_KEY,
fiBaseUrl: process.env.FI_BASE_URL,
});
});
it('should be able to list evaluations (basic connectivity test)', () => __awaiter(void 0, void 0, void 0, function* () {
try {
const evaluations = yield evaluator.list_evaluations();
expect(evaluations).toBeDefined();
expect(Array.isArray(evaluations)).toBe(true);
console.log(`✅ API is accessible. Found ${evaluations.length} evaluations.`);
}
catch (error) {
console.error('❌ API connectivity test failed:', error);
// Don't fail the test, just log the error
expect(true).toBe(true); // Always pass, this is just a health check
}
}), 10000);
it('should check API base URL format', () => {
const baseUrl = process.env.FI_BASE_URL;
console.log(`🔗 Using API Base URL: ${baseUrl}`);
if (baseUrl) {
expect(baseUrl.startsWith('http')).toBe(true);
console.log(`✅ Base URL format looks correct`);
}
else {
console.log(`⚠️ No base URL configured`);
}
});
it('should check environment variables', () => {
const apiKey = process.env.FI_API_KEY;
const secretKey = process.env.FI_SECRET_KEY;
const baseUrl = process.env.FI_BASE_URL;
console.log(`🔑 API Key present: ${!!apiKey}`);
console.log(`🔐 Secret Key present: ${!!secretKey}`);
console.log(`🌐 Base URL present: ${!!baseUrl}`);
if (apiKey)
console.log(`🔑 API Key length: ${apiKey.length} characters`);
if (secretKey)
console.log(`🔐 Secret Key length: ${secretKey.length} characters`);
expect(apiKey).toBeDefined();
expect(secretKey).toBeDefined();
expect(baseUrl).toBeDefined();
});
});
describeIf(!hasIntegrationEnv, 'API Health Check - Skipped', () => {
it('should skip health check when environment variables are not set', () => {
console.log('⏭️ Skipping API health check. Please set FI_API_KEY, FI_SECRET_KEY, and FI_BASE_URL environment variables.');
expect(true).toBe(true);
});
});
//# sourceMappingURL=api-health-check.test.js.map