Created
February 3, 2017 19:37
-
-
Save justinph/0ffd7b7a443b82e4941636b65067ad1a to your computer and use it in GitHub Desktop.
Webpage performance testing with nightmare.js - solo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let Nightmare = require('nightmare'); | |
let harPlugin = require('nightmare-har-plugin'); | |
let options = { | |
waitTimeout: 1000 | |
}; | |
harPlugin.install(Nightmare); | |
let nightmare = Nightmare(Object.assign(harPlugin.getDevtoolsOptions(), options)); | |
// expects URL passed in as arg | |
let url = process.argv[2]; | |
if (!url) { | |
process.exit(1); | |
} | |
nightmare | |
.viewport(1024, 768) | |
.waitForDevtools() | |
.goto(url) | |
.wait('body') | |
.getHAR() | |
.end() | |
.then((result) => { | |
let onLoad = result.pages[0].pageTimings.onLoad; | |
console.log(onLoad); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment