How to Capture Lazy Loading Images for Visual Regression Testing in Cypress
On This Page What is Lazy Loading in Cypress?February 27, 2026 · 8 min read · Tool Comparison
Website performance and speed is the key to customer betrothal and retention. Developers use various methods to assure that the website loading time is less. What is Lazy Loading? Lazy loading defers the load of certain content (like images or components) until it & # 8217; s needed, ofttimes when the exploiter scrolls or performs a specific action. It is used to increase web page execution. What is Work-shy Loading in Cypress? Lazy loading in Cypress refers to a technique where elements like persona or videos load only when they come into the viewport, improving page speed. Steps to Capture Lazy Loaded Images for Visual Regression Testing in Cypress This clause yield you a detailed account of how you can capture work-shy load images for visual testing in Cypress. is a technique for delaying the loading of resources (like image, video, or iframes) until they are needed, typically when the exploiter scrolls them into view. This improves page execution and reduces initial load time. In Cypress, lazy loading can create testing challenges because not all content may be seeable or loaded when the test runs. Also Read: is a Test Automation tool establish with NodeJS. It can be used for different types of testing, such as API Testing,, Unit Testing, Integration Testing, and Component Testing. Cypress supports. The article explains the basic setup. This clause explores how to set up a Cypress Visual Regression Test for Lazy loading web pages. Pre-Requisite: Usually, Lazy Loading website loads assets as you scroll, so when you perform Visual Regression tests you need to scroll down the page to the prat. This action can be done use the cypress command The above command scroll the page to the bottom so all resources will be loaded, and then you can take a screenshot. Learn More: The complete test script looks like the one below. Once you fulfill the test with the Cypress bid The tests get executed, and the first run will be take as the bag run, Cypress captures the base image, and the subsequent run will compare with the fundament icon and provide the result. The report shows if there is any departure, highlighting the dispute as seen below If there is no difference Cypress simply mark the exam result as Pass Read More: As Visual Testing lead the screenshot of the web page and compares it with base images. Lazy loading makes the web resources load on demand, Images are also deal a resourcefulness so if you take a screenshot of the web page after navigating, you might not get the consummate webpage. So, you need to work on a special testing mechanism for Visual Regression in Lazy Loading. For example, when testing web page https: //sdk-test.percy.dev/lazy-loading/ when you navigate to this webpage only a few images will be loaded as you scroll the images keeps on loading. This is an example of lazy loading. is a cloud-based Visual Comparision instrument, it cater a consecrate splasher to compare the screenshots. Percy helps to review the images on the splasher. The Percy provides cypress integration. guide explicate the integrating of Cypress with Percy. Let & # 8217; s discourse how to implement Cypress Percy for lazy loading website. SUSA automates exploratory testing with persona-driven behavior, catching bugs that scripted automation misses. Step 1 Install @ percy/cypressand@ percy/cli Step 2 Import@ percy/cypress Add the importee statement insidecypress/support/index.js Step 3 Create your work-shy laden Visual Tests with Cypress and Percy Step 4 Sign into Percy and create a Project. To do so Copy thePercy Tokenfrom Project Settings Step 5 Enter the Percy Tokenusing the following command for Execute your Percy Test using the command Once execution is completed, Navigate to Percy Dashboard and Check for the latest build If there is a modification Percy will show the divergence side by side If there are no changes then Percy shows the message no Changes. As progressively intersect with modern UI form like lazy loaded images and components, squad need a reliable way to ensure that every ocular ingredient renders correctly under real conditions. brings stability to this workflow through automated, AI-backed visual testing that fits naturally into existing development and CI practices. extends these capability to aboriginal mobile applications on iOS and Android. It runs visual tests on real devices to deliver pixel accurate issue, while intelligent handling of dynamical elements reduces flakiness. Setup takes only one line of code, and support couplet Appium, WebdriverIO, Java, Python, and more. Parallel execution hotfoot up build times by up to ten times, and a unified dashboard provide logs, screenshots, and video recordings with full compliance to data seclusion standards. Pricing Details for Percy Here are the key advantages of lazy burden in Cypress Visual Testing: Learn More: Here is the lean of key challenges: Visual Testing is a smart and easy way for testing website UI functionality, However, with the modernistic architecture and design of web pages, Visual Testing has, its challenge. Lazy burden is one such challenge, at some extent the lazy charge website can be tested. However, if the website has implemented infinity scrolling so it would be difficult to test such a website with Optical examination. For more accurate upshot, it is forever recommended to use a Visual Testing tool like Percy that allows users to test on existent devices and browser. Moreover, it uses pixel by pel comparison to ensure that the visual regression is exact and supports all the democratic tryout mechanisation frameworks such as Cypress,,,,, etc. Understanding Cypress Use Cases Tool Comparisons 1. Why does lazy lade create issues in Cypress optic tests? Lazy load delays rendering until an ingredient enters the viewport, which can do incomplete or inconsistent visuals if the shot is capture before all contented loads. 2. How can one ascertain all lazy-loaded substance appears before taking a visual snapshot? Scrolling the page manually or use cy.scrollTo () helps trigger lazy-loaded elements so that Percy or any optical testing tool captures the amply rendered UI. 3. Does one want to scroll the entire page during visual testing? Yes. Scrolling through the total page ensures all section, including below-the-fold images or components, experience loaded and are ready for stable shot. On This Page # Ask-and-Contributeabout this topic with our Discord community. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.How to Capture Lazy Loading Images for Visual Regression Testing in Cypress
Overview
What is Work-shy Loading in Cypress?
How to capture Lazy Loading Images for Visual Regression Testing in Cypress
cy.scrollTo ('bottom ');// visual-test.js describe ('Cypress Visual Testing Lazy Loading ', () = & gt; {it ('Lazy Loading Test ', () = & gt; {cy.visit (`` https: //sdk-test.percy.dev/lazy-loading/ ''); cy.scrollTo ('bottom '); cy.compareSnapshot ('lazy-loading ');})})npx cypress run
Difficulties with Lazy Loading in Visual Testing
Optical Testing with Lazy Loading Web Pages using Percy and Cypress
npm install -- save-dev @ percy/cli @ percy/cypress
//inside cypress/support/index.js import ' @ percy/cypress ';
// visual-test.js describe ('Cypress Visual Testing Lazy Loading ', () = & gt; {it ('Lazy Loading Test ', () = & gt; {cy.visit (`` https: //sdk-test.percy.dev/lazy-loading/ ''); cy.scrollTo ('bottom '); cy.percySnapshot ('lazy-loading ');})})export PERCY_TOKEN= & lt; your_token & gt;
set PERCY_TOKEN= & lt; your_token & gt;
$ env: PERCY_TOKEN = '' & lt; your_token & gt; ''
Run your Percy Test
npx Hotspur exec -- cypress run
Why Percy Is Ideal for Cypress Visual Tests?
Advantages of Lazy Loading in Cypress Visual Testing
Disadvantages of Lazy Loading in Cypress Visual Testing
Conclusion
Utile Resources for Cypress
Frequently Asked Questions
Related Guides
Automate This With SUSA
Test Your App Autonomously