23 lines
565 B
JavaScript
23 lines
565 B
JavaScript
/* eslint no-console: 0 */
|
|
import Nightmare from 'nightmare';
|
|
import './helpers';
|
|
|
|
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') {
|
|
console.log(message);
|
|
}
|
|
});
|
|
|
|
return nightmare;
|
|
}
|