fix logging tests
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 5m53s

This commit is contained in:
2025-12-09 14:00:52 -08:00
parent 40b6ea35c1
commit c1d5570e2e
2 changed files with 15 additions and 1 deletions

View File

@@ -9,8 +9,16 @@ const mocks = vi.hoisted(() => {
const resize = vi.fn(() => ({ webp })); const resize = vi.fn(() => ({ webp }));
const sharpInstance = { resize }; const sharpInstance = { resize };
// Mock the sharp function and attach static properties required by the implementation
const sharp = vi.fn(() => sharpInstance);
Object.assign(sharp, {
fit: {
cover: 'cover',
},
});
return { return {
sharp: vi.fn(() => sharpInstance), sharp,
resize, resize,
webp, webp,
toFile, toFile,

View File

@@ -41,6 +41,12 @@ export async function generateFlyerIcon(sourceImagePath: string, iconsDirectory:
return iconFileName; return iconFileName;
} catch (error) { } catch (error) {
logger.error('Failed to generate flyer icon:', { error, sourceImagePath }); logger.error('Failed to generate flyer icon:', { error, sourceImagePath });
// Add logging to ensure the underlying error is visible in test output or server logs
if (error instanceof Error) {
console.error('Error generating icon:', error.message, error.stack);
} else {
console.error('Error generating icon:', error);
}
throw new Error('Icon generation failed.'); throw new Error('Icon generation failed.');
} }
} }