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) {
|
2018-08-31 05:53:38 +00:00
|
|
|
const nightmare = new Nightmare({show: process.env.E2E_SHOW, typeInterval: 10, x: 0, y: 0})
|
|
|
|
.viewport(width, height);
|
2017-09-10 18:04:22 +00:00
|
|
|
|
2018-01-11 14:25:03 +00:00
|
|
|
nightmare.on('page', (type, message, error) => {
|
2017-09-10 18:04:22 +00:00
|
|
|
fail(error);
|
|
|
|
});
|
|
|
|
|
2018-01-26 07:01:26 +00:00
|
|
|
nightmare.on('dom-ready', function() {
|
|
|
|
nightmare.inject('js', `${__dirname}/nightmareModifiers.js`);
|
|
|
|
});
|
|
|
|
|
2018-01-11 14:25:03 +00:00
|
|
|
nightmare.on('console', (type, message) => {
|
2017-09-10 18:04:22 +00:00
|
|
|
if (type === 'error') {
|
|
|
|
fail(message);
|
|
|
|
}
|
|
|
|
if (type === 'log') {
|
2018-01-09 12:51:41 +00:00
|
|
|
// console.log(message);
|
2017-09-10 18:04:22 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return nightmare;
|
|
|
|
}
|
2018-02-20 09:00:19 +00:00
|
|
|
|
|
|
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|