Skip to content

Commit

Permalink
Removed comment block, improved readability
Browse files Browse the repository at this point in the history
  • Loading branch information
verlok committed Apr 2, 2024
1 parent b57a710 commit b1e13b8
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions tests/e2e/image_basic.spec.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
// @ts-check
import { expect, test } from "@playwright/test";

test("Esm webpage test", async ({ page }) => {
test("Basic usage", async ({ page }) => {
await page.goto("/demos/image_basic.html");

/* page.on('console', async (msg) => {
const msgArgs = msg.args();
const logValues = await Promise.all(msgArgs.map(async arg => await arg.jsonValue()));
console.log(...logValues);
});*/

// Find all images with data-src attribute
const lazyLoadImages = await page.locator('img[data-src]');

// Wait for page loaded
await page.waitForLoadState("load");

// For each image with data-src attribute, scroll into view and check if it loads
// For each image with data-src attribute, scroll into view and check if it loads
const imageCount = await lazyLoadImages.count()

for (let i = 0; i < imageCount; i++) {
Expand All @@ -25,6 +20,7 @@ test("Esm webpage test", async ({ page }) => {
await image.scrollIntoViewIfNeeded();

// Wait for lazy loaded image to have a src attribute
await expect(image).toHaveAttribute('src', await image.getAttribute('data-src'));
const expected = await image.getAttribute('data-src');
await expect(image).toHaveAttribute('src', expected);
}
});

0 comments on commit b1e13b8

Please sign in to comment.