@applitools/docker-compose-mocha
Advanced tools
Comparing version 2.0.5 to 3.0.0
@@ -21,2 +21,3 @@ // @flow | ||
const getLogsForService = require('./lib/get-logs-for-service'); | ||
const { setUpGcsBuckets, getLocksBucket, getConfigsBucket } = require('./lib/setup-gcs-buckets')(); | ||
@@ -78,2 +79,4 @@ function replaceFunctionsWithTheirValues(envVars) { | ||
beforeContainerCleanUp = () => {}, | ||
useConfigurationsBuckets = false, | ||
gcStorage, | ||
} | ||
@@ -140,2 +143,6 @@ /* :DockerComposeToolOptions */ = {})/* : string */ { | ||
} | ||
if (useConfigurationsBuckets) { | ||
await setUpGcsBuckets(gcStorage); | ||
} | ||
}); | ||
@@ -177,2 +184,4 @@ | ||
dockerUnpauseByServiceName, | ||
getLocksBucket, | ||
getConfigsBucket, | ||
}; |
@@ -14,4 +14,4 @@ const { exec } = require('child-process-promise'); | ||
const exist = lines.find((element) => { | ||
const containerName = `${runName}_${serviceName}`; | ||
return element.indexOf(containerName) > -1 && element.indexOf('Up') > -1; | ||
const containerName = `${runName}-${serviceName}`; | ||
return element.indexOf(containerName) > -1 && element.indexOf('Up') > -1 && element.indexOf('Paused') === -1; | ||
}); | ||
@@ -18,0 +18,0 @@ return Boolean(exist); |
@@ -5,4 +5,16 @@ // @flow | ||
module.exports = function dockerKillByContainerId(id/* : string */) { | ||
return exec(`docker rm -f -v ${id}`); | ||
module.exports = async function dockerKillByContainerId(id/* : string */) { | ||
let res; | ||
try { | ||
res = await exec(`docker rm -f -v ${id}`); | ||
} catch (e) { | ||
if (e.message.includes('is not running')) { | ||
console.log(`container ${id} is no longer running`); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
return res; | ||
}; |
@@ -71,3 +71,11 @@ // @flow | ||
await exec(`docker compose -p ${envName} -f "${pathToComposeFile}" ${brutallyKill ? 'kill' : 'down'}`, envVars ? { shell: getShell(), env: { PATH: process.env.PATH, ...envVars } } : { shell: getShell() }); | ||
try { | ||
await exec(`docker compose -p ${envName} -f "${pathToComposeFile}" ${brutallyKill ? 'kill' : 'down'}`, envVars ? { shell: getShell(), env: { PATH: process.env.PATH, ...envVars } } : { shell: getShell() }); | ||
} catch (e) { | ||
if (e.message.includes('is not running')) { | ||
console.log(`env ${envName} is no longer running`); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
@@ -85,3 +93,12 @@ const consoleMessageDispose = `Disposing of ${envDisplayName} environment.. `; | ||
await exec(`docker compose -p ${envName} -f "${pathToComposeFile}" down -v`, envVars ? { shell: getShell(), env: { PATH: process.env.PATH, ...envVars } } : { shell: getShell() }); | ||
try { | ||
await exec(`docker compose -p ${envName} -f "${pathToComposeFile}" down -v`, envVars ? { shell: getShell(), env: { PATH: process.env.PATH, ...envVars } } : { shell: getShell() }); | ||
} catch (e) { | ||
if (e.message.includes('is not running')) { | ||
console.log(`env ${envName} is no longer running`); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
if (!process.env.NOSPIN) { | ||
@@ -88,0 +105,0 @@ spinner2.stop(); |
@@ -8,3 +8,3 @@ // @flow | ||
const { exec } = childProcess; | ||
if (originalPort.toString().includes(':')) { | ||
if (originalPort?.toString().includes(':')) { | ||
// If the port is locked - we return it - no need to query for it with the code below | ||
@@ -11,0 +11,0 @@ return `0.0.0.0:${originalPort.split(':')[0]}`; |
{ | ||
"name": "@applitools/docker-compose-mocha", | ||
"version": "2.0.5", | ||
"version": "3.0.0", | ||
"description": "Tool used for setting up an isolated environment for end to end testing / integration testing using Docker Compose", | ||
@@ -31,2 +31,3 @@ "main": "index.js", | ||
"@applitools/sample-web-app-testkit": "^1.3.85", | ||
"@google-cloud/storage": "^7.12.1", | ||
"chai": "^4.2.0", | ||
@@ -37,5 +38,5 @@ "eslint": "^6.8.0", | ||
"flow-bin": "^0.116.1", | ||
"mocha": "^6.2.2", | ||
"mocha": "^10.7.3", | ||
"sinon": "^8.1.1" | ||
} | ||
} |
@@ -131,3 +131,3 @@ const { expect } = require('chai'); | ||
expect(checkBefore).to.eql(true); | ||
const address = await getAddressForService(generatedEnvName, pathToCompose, serviceName); | ||
const address = await getAddressForService(generatedEnvName, pathToCompose, serviceName, 3001); | ||
await dockerPauseByServiceName(generatedEnvName, | ||
@@ -144,3 +144,3 @@ pathToCompose, serviceName); | ||
const addressAfterPause = await getAddressForService(generatedEnvName, | ||
pathToCompose, serviceName); | ||
pathToCompose, serviceName, 3001); | ||
expect(address).to.eql(addressAfterPause); | ||
@@ -147,0 +147,0 @@ } catch (err) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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 6 instances 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
66856
51
1224
10
1
28