-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-pageload-performance.js
36 lines (25 loc) · 1021 Bytes
/
test-pageload-performance.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
import test from 'ava';
import chai from 'chai';
const PAGE_LOAD_THRESHOLD_MS = 5000;
const URL = "https://www.amazon.com/"
var dom_load_time = 0;
var client_load_time = 0;
var Glance = require("glance-webdriver").default;
var glance = new Glance({
driverConfig: { desiredCapabilities: {browserName: 'chrome'} }
});
chai.should(); //injects this method into all objects so you can use it
test("Amazon home page load performance", async t =>{
let loadTimes = await glance
.url(URL)
.execute(function(){
return performance.timing
});
console.log(loadTimes);
dom_load_time = loadTimes.domComplete - loadTimes.domLoading;
client_load_time = loadTimes.loadEventEnd - loadTimes.domLoading;
console.log("DOM load time is", loadTimes.domComplete - loadTimes.domLoading, "ms");
console.log("Client side time is", loadTimes.loadEventEnd - loadTimes.domLoading,"ms");
client_load_time.should.be.below(PAGE_LOAD_THRESHOLD_MS);
await glance.end();
});