2017-09-10 18:04:22 +00:00
|
|
|
/* eslint no-console: 0 */
|
|
|
|
import Nightmare from 'nightmare';
|
|
|
|
|
|
|
|
export default function createNightmare(width = 1100, height = 600) {
|
|
|
|
const nightmare = new Nightmare({show: true, typeInterval: 10}).viewport(width, height);
|
|
|
|
|
|
|
|
nightmare.on('page', function(type, message, error) {
|
|
|
|
fail(error);
|
|
|
|
});
|
|
|
|
|
|
|
|
nightmare.on('console', function(type, message) {
|
|
|
|
if (type === 'error') {
|
|
|
|
fail(message);
|
|
|
|
}
|
|
|
|
if (type === 'log') {
|
2017-12-05 14:28:48 +00:00
|
|
|
// console.log(message);
|
2017-09-10 18:04:22 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return nightmare;
|
|
|
|
}
|