-
Notifications
You must be signed in to change notification settings - Fork 12
/
report-network.spec.js
71 lines (53 loc) · 1.61 KB
/
report-network.spec.js
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
const fs = require('fs');
const path = require('path');
const { test } = require('@playwright/test');
const { attachNetworkReport } = require('monocart-reporter');
test('attach network report 1', async ({ browser }) => {
const harPath = path.resolve('.temp/network-report1.har');
if (fs.existsSync(harPath)) {
// remove previous
fs.rmSync(harPath);
}
const context = await browser.newContext({
recordHar: {
path: harPath
}
});
const page = await context.newPage();
await page.goto('http://localhost:8090/minify/', {
waitUntil: 'networkidle'
});
await new Promise((resolve) => {
setTimeout(resolve, 500);
});
// Close context to ensure HAR is saved to disk.
await context.close();
await attachNetworkReport(harPath, test.info(), {
// inline: true
});
});
test('attach network report 2', async ({ browser }) => {
const harPath = path.resolve('.temp/network-report2.har');
if (fs.existsSync(harPath)) {
// remove previous
fs.rmSync(harPath);
}
const context = await browser.newContext({
recordHar: {
path: harPath
}
});
const page = await context.newPage();
await page.goto('http://localhost:8090/v8/', {
waitUntil: 'networkidle'
});
await new Promise((resolve) => {
setTimeout(resolve, 500);
});
await new Promise((resolve) => {
setTimeout(resolve, 500);
});
// Close context to ensure HAR is saved to disk.
await context.close();
await attachNetworkReport(harPath, test.info());
});