-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathcheck-errors.cjs
More file actions
49 lines (40 loc) · 1.22 KB
/
Copy pathcheck-errors.cjs
File metadata and controls
49 lines (40 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const { chromium } = require('playwright');
(async () => {
const errors = [];
const browser = await chromium.launch();
const page = await browser.newPage();
page.on('console', msg => {
if (msg.type() === 'error') {
const text = msg.text();
console.log('BROWSER_CONSOLE_ERROR:', text);
errors.push(`Console Error: ${text}`);
}
});
page.on('pageerror', error => {
console.log('BROWSER_PAGE_ERROR:', error.message);
errors.push(`Page Error: ${error.message}`);
});
const url = process.env.TEST_URL || 'http://localhost:8080/learner-dashboard';
try {
await page.goto(url, { waitUntil: 'networkidle' });
} catch (e) {
console.log('Goto Error:', e.message);
errors.push(`Navigation Error: ${e.message}`);
}
try {
await page.waitForLoadState('networkidle');
} catch (e) {
errors.push(`Wait Error: ${e.message}`);
}
await browser.close();
console.log('\n--- Test Summary ---');
console.log(`Total Errors Found: ${errors.length}`);
if (errors.length > 0) {
console.error('Errors details:');
errors.forEach(err => console.error(`- ${err}`));
process.exit(1);
} else {
console.log('No errors detected.');
process.exit(0);
}
})();