@applitools/eyes.cypress
Advanced tools
Comparing version 2.1.6 to 3.0.1
{ | ||
"name": "@applitools/eyes.cypress", | ||
"version": "2.1.6", | ||
"version": "3.0.1", | ||
"main": "index.js", | ||
@@ -34,3 +34,3 @@ "license": "MIT", | ||
"@applitools/dom-capture": "^2.0.0", | ||
"@applitools/rendering-grid-client": "^2.0.6", | ||
"@applitools/rendering-grid-client": "^3.0.2", | ||
"body-parser": "1.18.2", | ||
@@ -37,0 +37,0 @@ "cors": "^2.8.4", |
@@ -1,2 +0,2 @@ | ||
/* global Cypress,cy,window,before */ | ||
/* global Cypress,cy,window,before,after */ | ||
'use strict'; | ||
@@ -15,2 +15,10 @@ const {extractResources, domNodesToCdt} = require('@applitools/rendering-grid-client/browser'); | ||
const batchEnd = poll(function({timeout}) { | ||
return sendRequest({command: 'batchEnd', data: {timeout}}); | ||
}); | ||
after(() => { | ||
return batchEnd({timeout: Cypress.config('eyesTimeout')}); | ||
}); | ||
Cypress.Commands.add('eyesOpen', function(args = {}) { | ||
@@ -66,9 +74,5 @@ const {title: testName} = this.currentTest || this.test; | ||
const close = poll(function({timeout}) { | ||
return sendRequest({command: 'close', data: {timeout}}); | ||
}); | ||
Cypress.Commands.add('eyesClose', ({timeout} = {}) => { | ||
Cypress.Commands.add('eyesClose', () => { | ||
Cypress.log({name: 'Eyes: close'}); | ||
return close({timeout}); | ||
return sendRequest({command: 'close'}); | ||
}); | ||
@@ -75,0 +79,0 @@ |
'use strict'; | ||
const pollingHandler = require('./pollingHandler'); | ||
const {PollingStatus} = pollingHandler; | ||
function makeHandlers({openEyes, getConfig, updateConfig, getInitialConfig, getBatch, logger}) { | ||
function makeHandlers({openEyes, batchStart, batchEnd}) { | ||
let checkWindow, close, resources; | ||
const pollBatchEnd = pollingHandler(batchEnd); | ||
return { | ||
open: async args => { | ||
const config = Object.assign(getConfig(args)); | ||
const eyes = await openEyes(config); | ||
const eyes = await openEyes(args); | ||
checkWindow = eyes.checkWindow; | ||
close = pollingHandler(eyes.close); | ||
close = eyes.close; | ||
resources = {}; | ||
@@ -18,8 +17,10 @@ return eyes; | ||
batchStart() { | ||
const defaultBatch = getBatch(getInitialConfig()); | ||
logger.log('new default batch', defaultBatch); | ||
updateConfig(defaultBatch); | ||
batchStart: args => { | ||
return batchStart(args); | ||
}, | ||
batchEnd: async ({timeout} = {}) => { | ||
return await pollBatchEnd(timeout); | ||
}, | ||
putResource: (id, buffer) => { | ||
@@ -69,3 +70,3 @@ if (!resources) { | ||
close: async ({timeout} = {}) => { | ||
close: async () => { | ||
if (!close) { | ||
@@ -76,11 +77,8 @@ throw new Error('Please call cy.eyesOpen() before calling cy.eyesClose()'); | ||
resources = null; | ||
let result; | ||
try { | ||
result = await close(timeout); | ||
return result; | ||
close(); // not returning this promise because we don't to wait on it before responding to the client | ||
} finally { | ||
if (!result || result.status === PollingStatus.DONE) { | ||
close = null; | ||
checkWindow = null; | ||
} | ||
close = null; | ||
checkWindow = null; | ||
} | ||
@@ -87,0 +85,0 @@ }, |
@@ -12,7 +12,8 @@ 'use strict'; | ||
const TIMEOUT_MSG = | ||
"The cy.eyesClose command timed out. The default timeout is 2 minutes. It's possible to increase this timeout by passing a larger value, e.g. for 3 minutes: cy.eyesClose({ timeout: 180000 })"; | ||
const TIMEOUT_MSG = (timeout = DEFAULT_TIMEOUT) => | ||
`The cy.eyesClose command timed out after ${timeout}ms. The default timeout is 2 minutes. It's possible to increase this timeout by passing a larger value, e.g. for 3 minutes: cy.eyesClose({ timeout: 180000 })`; | ||
function pollingHandler(doWork) { | ||
let timeoutId, | ||
timeoutUsed, | ||
pollingStatus = PollingStatus.IDLE, | ||
@@ -26,2 +27,3 @@ workError, | ||
pollingStatus = PollingStatus.WIP; | ||
timeoutUsed = timeout; | ||
timeoutId = setTimeout(() => { | ||
@@ -54,3 +56,5 @@ pollingStatus = PollingStatus.TIMEOUT; | ||
pollingStatus = PollingStatus.IDLE; | ||
throw new Error(TIMEOUT_MSG); | ||
const timeoutMsg = TIMEOUT_MSG(timeoutUsed); | ||
timeoutUsed = null; | ||
throw new Error(timeoutMsg); | ||
@@ -57,0 +61,0 @@ case PollingStatus.ERROR: |
'use strict'; | ||
const {promisify: p} = require('util'); | ||
const psetTimeout = p(setTimeout); | ||
const {openEyes, createLogger, getBatch} = require('@applitools/rendering-grid-client'); | ||
const logger = createLogger(); | ||
const { | ||
makeRenderingGridClient, | ||
initConfig, | ||
createLogger, | ||
} = require('@applitools/rendering-grid-client'); | ||
const logger = createLogger(process.env.APPLITOOLS_DEV_MODE); | ||
const {startApp} = require('./app'); | ||
const {initConfig} = require('./config'); | ||
const makeHandlers = require('./handlers'); | ||
const {getConfig, updateConfig, getInitialConfig} = initConfig(process.cwd()); | ||
const makeHandlers = require('./handlers'); | ||
const handlers = makeHandlers({ | ||
openEyes, | ||
const {batchStart, openEyes, batchEnd} = makeRenderingGridClient({ | ||
getConfig, | ||
updateConfig, | ||
getInitialConfig, | ||
getBatch, | ||
logger, | ||
}); | ||
const handlers = makeHandlers({ | ||
batchStart, | ||
openEyes, | ||
batchEnd, | ||
}); | ||
const makePluginExport = require('./pluginExport'); | ||
@@ -19,0 +24,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
4
29920
24
488
+ Added@applitools/rendering-grid-client@3.0.2(transitive)
- Removed@applitools/rendering-grid-client@2.0.6(transitive)