import test from 'node:test'; import assert from 'node:assert/strict'; import { logRealConsoleApiError } from './apiLogger.ts'; test('logRealConsoleApiError executes and outputs formatted error diagnostic', () => { let loggedError = false; const originalError = console.error; console.error = (...args) => { loggedError = true; }; try { logRealConsoleApiError({ topic: 'Test API Error Topic', endpoint: 'https://router.huggingface.co/hf-inference/v1/chat/completions', model: 'mistralai/Devstral-2-123B-Instruct-2512', status: 401, statusText: 'Unauthorized', message: 'Invalid access token provided', rawResponse: '{"error": "Authorization header is invalid"}', }); assert.equal(loggedError, true); } finally { console.error = originalError; } });