3.7 KiB
3.7 KiB
Instructions
- Following Playwright test failed.
- Explain why, be concise, respect Playwright best practices.
- Provide a snippet of code with the fix, if possible.
Test info
- Name: all.spec.js >> base project comprehensive tests and scrolling benchmarks
- Location: test/all.spec.js:3:1
Error details
Test timeout of 60000ms exceeded.
Error: page.waitForFunction: Test timeout of 60000ms exceeded.
Test source
1 | import { test, expect } from '@playwright/test';
2 |
3 | test('base project comprehensive tests and scrolling benchmarks', async ({ page }) => {
4 | test.setTimeout(60000);
5 | page.on('console', msg => console.log('BROWSER LOG:', msg.text()));
6 | await page.goto('http://127.0.0.1:8082/test/index.html');
7 |
8 | // Wait for testStatus to be set (includes basic unit tests and scrolling refresh test)
> 9 | await page.waitForFunction(() => window.testStatus !== undefined, { timeout: 60000 });
| ^ Error: page.waitForFunction: Test timeout of 60000ms exceeded.
10 |
11 | const status = await page.evaluate(() => window.testStatus);
12 | expect(status).toBe('passed');
13 |
14 | // Simulate real scrolling and check dynamic rendering for FastList
15 | console.log('Simulating real scroll on FastList...');
16 | const scrollInfo = await page.evaluate(async () => {
17 | window.switchTab?.('ll');
18 | await new Promise(r => setTimeout(r, 200)); // wait for render
19 | const el = document.getElementById('ll');
20 | const results = [];
21 |
22 | const getRenderedCount = () => el.querySelectorAll('.border-primary').length;
23 |
24 | results.push({
25 | id: 'initial',
26 | scrollTop: el.scrollTop,
27 | scrollHeight: el.scrollHeight,
28 | clientHeight: el.clientHeight,
29 | renderedCount: getRenderedCount(),
30 | renderedListLen: el.state.renderedList?.length
31 | });
32 |
33 | // Scroll to middle
34 | el.scrollTop = 50000;
35 | el.refresh?.();
36 | await new Promise(r => setTimeout(r, 500));
37 | const midCount = getRenderedCount();
38 | const midHtml = el.innerHTML.length;
39 | results.push({
40 | id: 'deep-middle',
41 | scrollTop: el.scrollTop,
42 | renderedCount: midCount,
43 | htmlLen: midHtml,
44 | prevHeight: el.state.prevHeight,
45 | postHeight: el.state.postHeight,
46 | renderedListLen: el.state._renderedList?.length
47 | });
48 |
49 | // Scroll to end
50 | el.scrollTop = el.scrollHeight;
51 | el.refresh?.();
52 | await new Promise(r => setTimeout(r, 500));
53 | results.push({
54 | id: 'end',
55 | scrollTop: el.scrollTop,
56 | renderedCount: getRenderedCount(),
57 | scrollHeight: el.scrollHeight,
58 | prevHeight: el.state.prevHeight,
59 | postHeight: el.state.postHeight
60 | });
61 |
62 | return results;
63 | });
64 |
65 | console.log('Scroll Details:', JSON.stringify(scrollInfo, null, 2));
66 | expect(scrollInfo[0].renderedCount).toBeGreaterThan(0);
67 | expect(scrollInfo[1].scrollTop).toBeGreaterThan(0);
68 |
69 | const bench = await page.evaluate(() => window.benchResults);
70 | if (bench) {
71 | Object.entries(bench).forEach(([name, time]) => {
72 | console.log(`BENCHMARK [${name}]: ${time.toFixed(2)}ms`);
73 | });
74 | }
75 | });
76 |