-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowserData.ts
More file actions
81 lines (69 loc) · 2.16 KB
/
Copy pathbrowserData.ts
File metadata and controls
81 lines (69 loc) · 2.16 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* eslint-disable @typescript-eslint/no-magic-numbers, no-console */
import {test} from 'autotests';
import {E2edReportExample} from 'autotests/pageObjects/pages';
import {createClientFunction, expect} from 'e2ed';
import {
getBrowserConsoleMessages,
getBrowserJsErrors,
navigateToPage,
waitForInterfaceStabilization,
} from 'e2ed/actions';
test(
'correctly read data from browser',
{meta: {testId: '14'}, viewportHeight: 1200, viewportWidth: 1600},
async () => {
await navigateToPage(E2edReportExample);
await createClientFunction(() => {
console.error('error');
console.info('info');
console.log('log');
console.warn('warning');
setTimeout(() => {
throw new Error('foo');
}, 100);
})();
const consoleMessages = getBrowserConsoleMessages();
const column = 12;
const columnNumber = column;
const url = '';
const consoleMessagesWithoutDate = consoleMessages.map(
({dateTimeInIso: _, ...messageWithoutDate}) => messageWithoutDate,
);
await expect(consoleMessagesWithoutDate, 'getBrowserConsoleMessages read all of messages').eql([
{
args: ['error'],
location: {column, columnNumber, line: 3, lineNumber: 3, url},
text: 'error',
type: 'error',
},
{
args: ['info'],
location: {column, columnNumber, line: 4, lineNumber: 4, url},
text: 'info',
type: 'info',
},
{
args: ['log'],
location: {column, columnNumber, line: 5, lineNumber: 5, url},
text: 'log',
type: 'log',
},
{
args: ['warning'],
location: {column, columnNumber, line: 6, lineNumber: 6, url},
text: 'warning',
type: 'warning',
},
]);
const jsErrors = getBrowserJsErrors();
await expect(
jsErrors.length,
'getBrowserJsErrors read zero JS errors when there are no errors',
).eql(0);
await waitForInterfaceStabilization(100);
await expect(jsErrors.length, 'getBrowserJsErrors read all JS errors').eql(1);
await expect(String(jsErrors[0]?.error), 'getBrowserJsErrors read all JS errors').contains(
'foo',
);
},
);