2017-09-10 18:04:22 +00:00
|
|
|
/* eslint no-console: 0 */
|
|
|
|
import Nightmare from 'nightmare';
|
|
|
|
|
2018-01-09 08:26:45 +00:00
|
|
|
export default function createNightmare(width = 1280, height = 720) {
|
|
|
|
const nightmare = new Nightmare({show: true, typeInterval: 10, x: 0, y: 0}).viewport(width, height);
|
2017-09-10 18:04:22 +00:00
|
|
|
|
|
|
|
nightmare.on('page', function(type, message, error) {
|
|
|
|
fail(error);
|
|
|
|
});
|
|
|
|
|
|
|
|
nightmare.on('console', function(type, message) {
|
|
|
|
if (type === 'error') {
|
|
|
|
fail(message);
|
|
|
|
}
|
|
|
|
if (type === 'log') {
|
2018-01-09 08:26:45 +00:00
|
|
|
console.log(message);
|
2017-09-10 18:04:22 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return nightmare;
|
|
|
|
}
|