30 lines
683 B
JavaScript
30 lines
683 B
JavaScript
/* eslint no-console: 0 */
|
|
import Nightmare from 'nightmare';
|
|
|
|
let nightmare;
|
|
|
|
export default function createNightmare(width = 1280, height = 720) {
|
|
if (nightmare)
|
|
return nightmare;
|
|
|
|
nightmare = new Nightmare({
|
|
show: process.env.E2E_SHOW,
|
|
typeInterval: 10,
|
|
x: 0,
|
|
y: 0,
|
|
waitTimeout: 2000
|
|
}).viewport(width, height);
|
|
|
|
nightmare.on('console', (type, message, ...args) => {
|
|
if (type === 'error')
|
|
throw new Error(message);
|
|
else
|
|
console[type](message, ...args);
|
|
});
|
|
|
|
nightmare.header('Accept-Language', 'en');
|
|
return nightmare;
|
|
}
|
|
|
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|