@applitools/rendering-grid-client
Advanced tools
Comparing version 3.0.2 to 4.0.1
{ | ||
"name": "@applitools/rendering-grid-client", | ||
"version": "3.0.2", | ||
"version": "4.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "src/rendering-grid-client.js", |
@@ -28,3 +28,2 @@ 'use strict'; | ||
renderWrapper, | ||
results, | ||
}) { | ||
@@ -123,5 +122,3 @@ return async function checkWindow({ | ||
results.push( | ||
await wrapper.checkWindow({screenshotUrl: imageLocation, tag, domUrl, checkSettings}), | ||
); | ||
await wrapper.checkWindow({screenshotUrl: imageLocation, tag, domUrl, checkSettings}); | ||
} | ||
@@ -128,0 +125,0 @@ |
'use strict'; | ||
function makeCloseEyes({getError, logger, getCheckWindowPromises, wrappers, results}) { | ||
function makeCloseEyes({getError, logger, getCheckWindowPromises, wrappers}) { | ||
return async function closeEyes() { | ||
@@ -15,8 +15,3 @@ let error; | ||
} | ||
await Promise.all(wrappers.map(wrapper => wrapper.close())); | ||
if ((error = getError())) { | ||
logger.log('closeEyes() aborting after close'); | ||
throw error; | ||
} | ||
return results; | ||
return await Promise.all(wrappers.map(wrapper => wrapper.close())); | ||
}; | ||
@@ -23,0 +18,0 @@ } |
@@ -34,6 +34,8 @@ 'use strict'; | ||
logger.log(`running with initial config: ${JSON.stringify(initialConfig)}`); | ||
return { | ||
getConfig(config) { | ||
const ret = Object.assign({}, priorConfig, config); | ||
logger.log(`running with config: ${JSON.stringify(ret)}`); | ||
logger.log(`getConfig ${JSON.stringify(ret)}`); | ||
return ret; | ||
@@ -40,0 +42,0 @@ }, |
@@ -16,3 +16,3 @@ 'use strict'; | ||
function makeOpenEyes({getError, setError, getClosePromises}) { | ||
function makeOpenEyes({getError, setError, handleClosePromise}) { | ||
return async function openEyes({ | ||
@@ -63,4 +63,2 @@ appName, | ||
let checkWindowPromises = []; | ||
const results = []; | ||
let error; | ||
@@ -106,5 +104,5 @@ const browsers = Array.isArray(browser) ? browser : [browser]; | ||
if (err.response && err.response.status === 401) { | ||
throw new Error('Unauthorized access to Eyes server. Please check your API key.'); | ||
setError(new Error('Unauthorized access to Eyes server. Please check your API key.')); | ||
} else { | ||
throw err; | ||
setError(err); | ||
} | ||
@@ -147,6 +145,5 @@ }); | ||
renderWrapper, | ||
results, | ||
}); | ||
const closeEyes = makeCloseEyes({getError, logger, getCheckWindowPromises, wrappers, results}); | ||
const closeEyes = makeCloseEyes({getError, logger, getCheckWindowPromises, wrappers}); | ||
@@ -173,10 +170,5 @@ return { | ||
async function close() { | ||
if (error) { | ||
logger.log('close() aborting when started'); | ||
throw error; | ||
} | ||
const promise = closeEyes().catch(setError); | ||
getClosePromises().push(promise); | ||
return promise; | ||
const closePromise = closeEyes(); | ||
handleClosePromise(closePromise); | ||
return closePromise; | ||
} | ||
@@ -183,0 +175,0 @@ }; |
@@ -5,44 +5,21 @@ 'use strict'; | ||
const makeOpenEyes = require('./openEyes'); | ||
const makeBatchEnd = require('./batchEnd'); | ||
const {presult} = require('@applitools/functional-commons'); | ||
function makeRenderingGridClient({ | ||
getConfig, | ||
updateConfig, | ||
getInitialConfig, | ||
showLogs: globalShowLogs, | ||
}) { | ||
function makeRenderingGridClient({getConfig, updateConfig, getInitialConfig, showLogs}) { | ||
let error; | ||
let closePromises = []; | ||
const globalLogger = createLogger(globalShowLogs); | ||
const openEyes = makeOpenEyes({setError, getError, getClosePromises}); | ||
const logger = createLogger(showLogs); | ||
const openEyes = makeOpenEyes({setError, getError, handleClosePromise}); | ||
const batchEnd = makeBatchEnd({logger, closePromises, getError}); | ||
const defaultBatch = getBatch(getInitialConfig()); | ||
logger.log('new default batch', defaultBatch); | ||
updateConfig(defaultBatch); | ||
return { | ||
openEyes: openEyesWithConfig, | ||
batchStart, | ||
batchEnd, | ||
}; | ||
function batchStart() { | ||
error = null; | ||
closePromises = []; | ||
const defaultBatch = getBatch(getInitialConfig()); | ||
globalLogger.log('new default batch', defaultBatch); | ||
updateConfig(defaultBatch); | ||
} | ||
async function batchEnd() { | ||
if (error) { | ||
globalLogger.log('batchEnd() aborting when started'); | ||
throw error; | ||
} | ||
const results = await Promise.all(closePromises); | ||
if (error) { | ||
globalLogger.log('batchEnd() aborting after closes'); | ||
throw error; | ||
} | ||
return results; | ||
} | ||
function setError(err) { | ||
@@ -56,4 +33,5 @@ error = err; | ||
function getClosePromises() { | ||
return closePromises; | ||
function handleClosePromise(promise) { | ||
const handledPromise = presult(promise); | ||
closePromises.push(handledPromise); | ||
} | ||
@@ -60,0 +38,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
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
49752
38
1436