2017-09-10 18:04:22 +00:00
|
|
|
/* eslint no-console: 0 */
|
|
|
|
import Nightmare from 'nightmare';
|
2019-01-23 14:34:16 +00:00
|
|
|
let nightmare;
|
2017-09-10 18:04:22 +00:00
|
|
|
|
2018-01-09 08:26:45 +00:00
|
|
|
export default function createNightmare(width = 1280, height = 720) {
|
2019-01-23 14:34:16 +00:00
|
|
|
if (nightmare)
|
|
|
|
return nightmare;
|
|
|
|
|
|
|
|
nightmare = new Nightmare({
|
2019-01-21 14:21:24 +00:00
|
|
|
show: process.env.E2E_SHOW,
|
|
|
|
typeInterval: 10,
|
|
|
|
x: 0,
|
|
|
|
y: 0,
|
|
|
|
waitTimeout: 2000
|
|
|
|
}).viewport(width, height);
|
2017-09-10 18:04:22 +00:00
|
|
|
|
2019-01-21 14:21:24 +00:00
|
|
|
nightmare.on('console', (type, message, ...args) => {
|
2018-11-21 15:59:09 +00:00
|
|
|
if (type === 'error')
|
2019-01-22 14:55:58 +00:00
|
|
|
throw new Error(message);
|
2019-01-21 14:21:24 +00:00
|
|
|
else
|
|
|
|
console[type](message, ...args);
|
2017-09-10 18:04:22 +00:00
|
|
|
});
|
2018-10-24 08:57:14 +00:00
|
|
|
|
|
|
|
nightmare.header('Accept-Language', 'en');
|
|
|
|
|
2017-09-10 18:04:22 +00:00
|
|
|
return nightmare;
|
|
|
|
}
|
2018-02-20 09:00:19 +00:00
|
|
|
|
|
|
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|