fix(sr): sr hydration and load was not working, Screenshot Comparison, and Testing (#4814)

This commit is contained in:
Alireza authored and GitHub committed 2025-02-26 11:23:40 -05:00
1 parent 1f5c60bbda
commit 9233143b9d
23 files changed
+213 -21

No files matched your search

+8 -3
View File
@@ -17,19 +17,24 @@ const checkForScreenshot = async (
delay = 100
) => {
await page.waitForLoadState('networkidle');
for (let i = 1; i < attempts; i++) {
for (let i = 0; i < attempts; i++) {
try {
await expect(locator).toHaveScreenshot(screenshotPath, {
maxDiffPixelRatio: 0.1,
});
return true;
} catch (error) {
if (i === attempts) {
throw new Error('Screenshot does not match.');
if (i === attempts - 1) {
console.debug('Screenshot comparison failed after all attempts');
throw error; // Throw the original error with details instead of a generic message
}
await new Promise(resolve => setTimeout(resolve, delay));
}
}
// This is a fallback in case the loop exits unexpectedly
throw new Error('Screenshot comparison failed: loop exited without match or proper error');
};
export { checkForScreenshot };