From b884006cb25e7ab78aa1fcaebfa72b7782f8acb8 Mon Sep 17 00:00:00 2001 From: Khadreal Date: Thu, 9 Jan 2025 12:38:19 +0100 Subject: [PATCH] Clean up, fix error --- src/support/steps/lcp-beacon-script.ts | 4 ++-- utils/helpers.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/support/steps/lcp-beacon-script.ts b/src/support/steps/lcp-beacon-script.ts index 288f361..06972e3 100644 --- a/src/support/steps/lcp-beacon-script.ts +++ b/src/support/steps/lcp-beacon-script.ts @@ -248,13 +248,13 @@ Then('lcp and atf images are not written to LL format', async function (this: IC const expected = jsonData[key]; const lcpResult = await checkLcpOrViewport(lcpLLImages, key, 'LCP', expected.lcp); - if (!lcpResult.isValid) { + if (lcpResult && !lcpResult.isValid) { truthy = false; failMsg += lcpResult.errorMessages.join(''); } const viewportResult = await checkLcpOrViewport(lcpLLImages, key, 'Viewport', expected.viewport); - if (!viewportResult.isValid) { + if (viewportResult && !viewportResult.isValid) { truthy = false; failMsg += viewportResult.errorMessages.join(''); } diff --git a/utils/helpers.ts b/utils/helpers.ts index c7058d7..6219544 100644 --- a/utils/helpers.ts +++ b/utils/helpers.ts @@ -73,10 +73,10 @@ const getDir = async (file: string): Promise => { /** * Check LCP/ATF images does not have lazyload attribute, either as image or background-image */ -export const checkLcpOrViewport: (images: LLImagesData, type: string, key: string, values: string[]) => Promise<{ +export const checkLcpOrViewport = async (images: LLImagesData, type: string, key: string, values: string[]): Promise<{ isValid: boolean; errorMessages: string[] -}> = async (images: LLImagesData, type: string, key: string, values: string[]) => { +}> => { let result = { lcpImage: '', lcpLLStatus: true, @@ -108,9 +108,9 @@ export const checkLcpOrViewport: (images: LLImagesData, type: string, key: strin `Expected ${type} for - ${value} for ${lcpUrl} is lazyloaded - ${result.lcpImage}\n\n\n` ); } - - return { isValid, errorMessages }; } + + return { isValid, errorMessages }; } /** * Read the content of a file.