2019-01-11 21:58:28 +00:00
|
|
|
/* eslint-disable */
|
|
|
|
const page = require('webpage').create();
|
|
|
|
const system = require('system');
|
|
|
|
const args = system.args;
|
|
|
|
|
2019-01-17 00:03:36 +00:00
|
|
|
const fixtures = args
|
|
|
|
.slice(1)[0]
|
|
|
|
.slice(0, -1)
|
|
|
|
.split(',');
|
2019-01-11 21:58:28 +00:00
|
|
|
const totalRenders = fixtures.length;
|
|
|
|
|
|
|
|
var renderCount = 0;
|
|
|
|
function pageRenderComplete() {
|
|
|
|
renderCount++;
|
|
|
|
if (renderCount === totalRenders) {
|
|
|
|
phantom.exit();
|
|
|
|
} else {
|
|
|
|
capturePage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function capturePage() {
|
2019-01-17 00:03:36 +00:00
|
|
|
const fixturePath = fixtures[renderCount];
|
2019-01-11 21:58:28 +00:00
|
|
|
page.viewportSize = { width: 1366, height: 768 };
|
|
|
|
|
|
|
|
page.open(fixturePath, function() {
|
|
|
|
// set default background to white (otherwise can sometimes get transparent bg in png
|
2019-01-17 00:03:36 +00:00
|
|
|
const script =
|
|
|
|
"function() { \
|
2019-01-11 21:58:28 +00:00
|
|
|
var style = document.createElement('style'); \
|
|
|
|
var text = document.createTextNode('body { background: #fff }'); \
|
|
|
|
style.setAttribute('type', 'text/css'); \
|
|
|
|
style.appendChild(text); \
|
|
|
|
document.head.insertBefore(style, document.head.firstChild); \
|
|
|
|
}";
|
|
|
|
|
|
|
|
page.evaluateJavaScript(script);
|
|
|
|
|
|
|
|
var filename = new Date();
|
2019-01-14 19:18:32 +00:00
|
|
|
page.clipRect = { top: 0, left: 0, width: 1366, height: 768 };
|
2019-01-11 21:58:28 +00:00
|
|
|
page.render('tmp/artifacts/' + fixturePath + '.png');
|
|
|
|
pageRenderComplete();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
capturePage();
|