tiny-vue_version0/examples/sites/demos/pc/app/image/lazy.spec.ts

20 lines
677 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { test, expect } from '@playwright/test'
test('测试懒加载', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('image#lazy')
const preview = page.locator('.pc-demo-container')
await expect(preview.locator('.demo-image__lazy div').locator('img')).toHaveCount(1)
// 滚动2次触发下面2张加载
const imageBox = preview.locator('.demo-image__lazy')
await imageBox.hover()
await page.mouse.wheel(0, 300)
await page.waitForTimeout(100)
await page.mouse.wheel(0, 500)
await page.waitForTimeout(30)
await expect(preview.locator('.demo-image__lazy').locator('img')).toHaveCount(3)
})