Skip to content

Instantly share code, notes, and snippets.

@justinph
Created February 3, 2017 19:37
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinph/0ffd7b7a443b82e4941636b65067ad1a to your computer and use it in GitHub Desktop.
Save justinph/0ffd7b7a443b82e4941636b65067ad1a to your computer and use it in GitHub Desktop.
Webpage performance testing with nightmare.js - solo
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