@applitools/eyes.cypress
Advanced tools
Comparing version 1.3.5 to 1.3.6
{ | ||
"name": "@applitools/eyes.cypress", | ||
"version": "1.3.5", | ||
"version": "1.3.6", | ||
"main": "index.js", | ||
@@ -11,3 +11,3 @@ "license": "MIT", | ||
"build": "#", | ||
"cypress": "cd tests/fixtures/testApp && cypress open --config integrationFolder=cypress/integration-timeout,pluginsFile=cypress/plugins/index-run.js,supportFile=cypress/support/index-run.js" | ||
"cypress": "cd tests/fixtures/testApp && cypress open --config integrationFolder=cypress/integration-play,pluginsFile=cypress/plugins/index-run.js,supportFile=cypress/support/index-run.js" | ||
}, | ||
@@ -14,0 +14,0 @@ "files": [ |
@@ -5,11 +5,13 @@ /* global fetch, Cypress, cy */ | ||
const domNodesToCdt = require('../render-grid/browser-util/domNodesToCdt'); | ||
const poll = require('./poll'); | ||
const makeSend = require('./makeSend'); | ||
const send = makeSend(Cypress.config('eyesPort') || require('./defaultPort'), fetch); | ||
const port = Cypress.config('eyesPort') || require('./plugin/defaultPort'); | ||
const send = makeSend(port, fetch); | ||
const EyesServer = { | ||
open(args) { | ||
return this._send('open', args).catch(ex => { | ||
return sendRequest('open', args).catch(ex => { | ||
if (ex.message === 'Failed to fetch') { | ||
throw new Error( | ||
"Eyes.Cypress communication failure. Maybe you used a custom plugin port and didn't export it as eyesPort from the pluginsFile? Check your pluginsFile (normally located at cypress/plugins/index.js) for the require('@applitools/eyes.cypress') statement.", | ||
`Eyes.Cypress communication failure. Configured eyesPort is ${port}. Maybe you used a custom plugin port and didn't export it as eyesPort from the pluginsFile? Check your pluginsFile (normally located at cypress/plugins/index.js) for the require('@applitools/eyes.cypress') statement.`, | ||
); | ||
@@ -23,22 +25,8 @@ } else { | ||
checkWindow(resourceUrls, cdt, tag) { | ||
return this._send('checkWindow', {resourceUrls, cdt, tag}); | ||
return sendRequest('checkWindow', {resourceUrls, cdt, tag}); | ||
}, | ||
close({timeout}) { | ||
return this._send('close', {timeout}); | ||
}, | ||
_send: function(command, data) { | ||
let resp; | ||
return send(command, data) | ||
.then(_resp => { | ||
resp = _resp; | ||
return resp.text(); | ||
}) | ||
.then(text => { | ||
if (resp.status === 500) { | ||
return Promise.reject(text); | ||
} | ||
}); | ||
}, | ||
close: poll(function({timeout}) { | ||
return sendRequest('close', {timeout}); | ||
}), | ||
}; | ||
@@ -65,3 +53,24 @@ | ||
Cypress.log({name: 'Eyes: close'}); | ||
return EyesServer.close({timeout}); | ||
return EyesServer.close({timeout}).catch(ex => { | ||
console.log('bbb', ex); | ||
}); | ||
}); | ||
function sendRequest(command, data) { | ||
let resp; | ||
return send(command, data) | ||
.then(_resp => { | ||
resp = _resp; | ||
if (resp.status === 500) { | ||
return resp.text(); | ||
} else { | ||
return resp.json(); | ||
} | ||
}) | ||
.then(result => { | ||
if (resp.status === 500) { | ||
return Promise.reject(result); | ||
} | ||
return result; | ||
}); | ||
} |
@@ -1,3 +0,3 @@ | ||
module.exports = (port, fetch) => (command, data) => { | ||
return fetch(`http://localhost:${port}/eyes/${command}`, { | ||
module.exports = (port, fetch) => (command, data) => | ||
fetch(`http://localhost:${port}/eyes/${command}`, { | ||
method: 'POST', | ||
@@ -10,2 +10,1 @@ body: data ? JSON.stringify(data) : undefined, | ||
}); | ||
}; |
46201
30
1057