···452452 expect(result).toBeNull();
453453 });
454454455455- test("should handle errors when file is missing", async () => {
456456- try {
457457- await getImageSize("/path/to/missing.jpg");
458458- // If we reach here, the test should fail
459459- expect(true).toBe(false);
460460- } catch (error) {
461461- expect(error).toBeDefined();
462462- expect((error as Error).message).toContain("Input file is missing");
463463- }
455455+ test("should log error when image processing fails", async () => {
456456+ // Import the logger mock
457457+ const { logger } = require("../logger/logger");
458458+459459+ // Call the function with a path that will trigger an error
460460+ const result = await getImageSize("/path/to/missing.jpg");
461461+462462+ // Verify the logger.error was called with the expected message pattern
463463+ expect(logger.error).toHaveBeenCalled();
464464+ expect(logger.error).toHaveBeenCalledWith(
465465+ expect.stringMatching(/Failed to get image aspect ratio; image path: \/path\/to\/missing\.jpg, error:/)
466466+ );
467467+468468+ // Verify the function returns null when an error occurs
469469+ expect(result).toBeNull();
464470 });
465471});