diff --git a/.eslintrc.js b/.eslintrc.js index 1ad6ac3..a7ab164 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,7 +3,6 @@ module.exports = { 'eslint:recommended', 'plugin:jest/recommended', 'plugin:@typescript-eslint/recommended', - 'prettier/@typescript-eslint', 'plugin:prettier/recommended' ], env: { diff --git a/src/index.ts b/src/index.ts index cc4fe17..06aa4d7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,31 +1,31 @@ -import childProcess from 'child_process'; +import childProcess from 'child_process' import { Readable } from 'stream' export interface IDockerComposeOptions { - cwd?: string; - config?: string | string[]; - configAsString?: string; - log?: boolean; - composeOptions?: string[] | (string | string[])[]; - commandOptions?: string[] | (string | string[])[]; - env?: NodeJS.ProcessEnv; + cwd?: string + config?: string | string[] + configAsString?: string + log?: boolean + composeOptions?: string[] | (string | string[])[] + commandOptions?: string[] | (string | string[])[] + env?: NodeJS.ProcessEnv } export interface IDockerComposeLogOptions extends IDockerComposeOptions { - follow?: boolean; + follow?: boolean } export interface IDockerComposeBuildOptions extends IDockerComposeOptions { - parallel?: boolean; + parallel?: boolean } export interface IDockerComposePushOptions extends IDockerComposeOptions { - ignorePushFailures?: boolean; + ignorePushFailures?: boolean } export interface IDockerComposeResult { - exitCode: number | null; - out: string; - err: string; + exitCode: number | null + out: string + err: string } /** @@ -34,231 +34,328 @@ export interface IDockerComposeResult { */ const configToArgs = (config): string[] => { if (typeof config === 'undefined') { - return []; + return [] } else if (typeof config === 'string') { - return [ '-f', config ]; + return ['-f', config] } else if (config instanceof Array) { - return config.reduce((args, item): string[] => args.concat([ '-f', item ]), []); + return config.reduce( + (args, item): string[] => args.concat(['-f', item]), + [] + ) } - throw new Error(`Invalid argument supplied: ${config}`); -}; + throw new Error(`Invalid argument supplied: ${config}`) +} /** * Converts docker-compose commandline options to cli arguments */ const composeOptionsToArgs = (composeOptions): string[] => { - let composeArgs: string[] = []; + let composeArgs: string[] = [] composeOptions.forEach((option: string[] | string): void => { if (option instanceof Array) { - composeArgs = composeArgs.concat(option); + composeArgs = composeArgs.concat(option) } if (typeof option === 'string') { - composeArgs = composeArgs.concat([ option ]); + composeArgs = composeArgs.concat([option]) } - }); + }) - return composeArgs; -}; + return composeArgs +} /** * Executes docker-compose command with common options */ -const execCompose = (command, args, options: IDockerComposeOptions = {}): Promise => new Promise((resolve, reject): void => { - const composeOptions = options.composeOptions || []; - const commandOptions = options.commandOptions || []; - let composeArgs = composeOptionsToArgs(composeOptions); - const isConfigProvidedAsString = !!options.configAsString; +const execCompose = ( + command, + args, + options: IDockerComposeOptions = {} +): Promise => + new Promise((resolve, reject): void => { + const composeOptions = options.composeOptions || [] + const commandOptions = options.commandOptions || [] + let composeArgs = composeOptionsToArgs(composeOptions) + const isConfigProvidedAsString = !!options.configAsString - const configArgs = isConfigProvidedAsString ? [ '-f', '-' ] : configToArgs(options.config); + const configArgs = isConfigProvidedAsString + ? ['-f', '-'] + : configToArgs(options.config) - composeArgs = composeArgs.concat(configArgs.concat([ command ].concat(composeOptionsToArgs(commandOptions), args))); + composeArgs = composeArgs.concat( + configArgs.concat( + [command].concat(composeOptionsToArgs(commandOptions), args) + ) + ) - const cwd = options.cwd; - const env = options.env || undefined; + const cwd = options.cwd + const env = options.env || undefined - const childProc = childProcess.spawn('docker-compose', composeArgs, { cwd, env }); + const childProc = childProcess.spawn('docker-compose', composeArgs, { + cwd, + env + }) - childProc.on('error', (err): void => { - reject(err); - }); + childProc.on('error', (err): void => { + reject(err) + }) - const result: IDockerComposeResult = { - exitCode: null, - err: '', - out: '' - }; - - childProc.stdout.on('data', (chunk): void => { - result.out += chunk.toString(); - }); - - childProc.stderr.on('data', (chunk): void => { - result.err += chunk.toString(); - }); - - childProc.on('exit', (exitCode): void => { - result.exitCode = exitCode; - if (exitCode === 0) { - resolve(result); - } else { - reject(result); + const result: IDockerComposeResult = { + exitCode: null, + err: '', + out: '' } - }); - if (isConfigProvidedAsString) { - childProc.stdin.write(options.configAsString); - childProc.stdin.end(); - } + childProc.stdout.on('data', (chunk): void => { + result.out += chunk.toString() + }) - if (options.log) { - childProc.stdout.pipe(process.stdout); - childProc.stderr.pipe(process.stderr); - } -}); + childProc.stderr.on('data', (chunk): void => { + result.err += chunk.toString() + }) + + childProc.on('exit', (exitCode): void => { + result.exitCode = exitCode + if (exitCode === 0) { + resolve(result) + } else { + reject(result) + } + }) + + if (isConfigProvidedAsString) { + childProc.stdin.write(options.configAsString) + childProc.stdin.end() + } + + if (options.log) { + childProc.stdout.pipe(process.stdout) + childProc.stderr.pipe(process.stderr) + } + }) /** * Determines whether or not to use the default non-interactive flag -d for up commands */ -const shouldUseDefaultNonInteractiveFlag = function(options: IDockerComposeOptions = {}): boolean { - const commandOptions = options.commandOptions || []; - const containsOtherNonInteractiveFlag = commandOptions.reduce((memo: boolean, item: string | string[]) => { - return memo && !item.includes('--abort-on-container-exit') && !item.includes('--no-start'); - }, true); - return containsOtherNonInteractiveFlag; -}; +const shouldUseDefaultNonInteractiveFlag = function ( + options: IDockerComposeOptions = {} +): boolean { + const commandOptions = options.commandOptions || [] + const containsOtherNonInteractiveFlag = commandOptions.reduce( + (memo: boolean, item: string | string[]) => { + return ( + memo && + !item.includes('--abort-on-container-exit') && + !item.includes('--no-start') + ) + }, + true + ) + return containsOtherNonInteractiveFlag +} -export const upAll = function (options?: IDockerComposeOptions): Promise { - const args = shouldUseDefaultNonInteractiveFlag(options) ? [ '-d' ] : []; - return execCompose('up', args, options); -}; +export const upAll = function ( + options?: IDockerComposeOptions +): Promise { + const args = shouldUseDefaultNonInteractiveFlag(options) ? ['-d'] : [] + return execCompose('up', args, options) +} -export const upMany = function (services: string[], options?: IDockerComposeOptions): Promise { - const args = shouldUseDefaultNonInteractiveFlag(options) ? [ '-d' ].concat(services) : services; - return execCompose('up', args, options); -}; +export const upMany = function ( + services: string[], + options?: IDockerComposeOptions +): Promise { + const args = shouldUseDefaultNonInteractiveFlag(options) + ? ['-d'].concat(services) + : services + return execCompose('up', args, options) +} -export const upOne = function (service: string, options?: IDockerComposeOptions): Promise { - const args = shouldUseDefaultNonInteractiveFlag(options) ? [ '-d', service ] : [ service ]; - return execCompose('up', args, options); -}; +export const upOne = function ( + service: string, + options?: IDockerComposeOptions +): Promise { + const args = shouldUseDefaultNonInteractiveFlag(options) + ? ['-d', service] + : [service] + return execCompose('up', args, options) +} -export const down = function (options?: IDockerComposeOptions): Promise { - return execCompose('down', [], options); -}; +export const down = function ( + options?: IDockerComposeOptions +): Promise { + return execCompose('down', [], options) +} -export const stop = function (options?: IDockerComposeOptions): Promise { - return execCompose('stop', [], options); -}; +export const stop = function ( + options?: IDockerComposeOptions +): Promise { + return execCompose('stop', [], options) +} -export const stopOne = function (service: string, options?: IDockerComposeOptions): Promise { - return execCompose('stop', [ service ], options); -}; +export const stopOne = function ( + service: string, + options?: IDockerComposeOptions +): Promise { + return execCompose('stop', [service], options) +} -export const kill = function (options?: IDockerComposeOptions): Promise { - return execCompose('kill', [], options); -}; +export const kill = function ( + options?: IDockerComposeOptions +): Promise { + return execCompose('kill', [], options) +} -export const rm = function (options?: IDockerComposeOptions, ...services: string[]): Promise { - return execCompose('rm', [ '-f', ...services ], options); -}; +export const rm = function ( + options?: IDockerComposeOptions, + ...services: string[] +): Promise { + return execCompose('rm', ['-f', ...services], options) +} -export const exec = function (container: string, command: string | string[], options?: IDockerComposeOptions): Promise { - const args = Array.isArray(command) ? command : command.split(/\s+/); +export const exec = function ( + container: string, + command: string | string[], + options?: IDockerComposeOptions +): Promise { + const args = Array.isArray(command) ? command : command.split(/\s+/) - return execCompose('exec', [ '-T', container ].concat(args), options); -}; + return execCompose('exec', ['-T', container].concat(args), options) +} -export const run = function (container: string, command: string | string[], options?: IDockerComposeOptions): Promise { - const args = Array.isArray(command) ? command : command.split(/\s+/); +export const run = function ( + container: string, + command: string | string[], + options?: IDockerComposeOptions +): Promise { + const args = Array.isArray(command) ? command : command.split(/\s+/) - return execCompose('run', [ '-T', container ].concat(args), options); -}; + return execCompose('run', ['-T', container].concat(args), options) +} -export const buildAll = function (options: IDockerComposeBuildOptions = {}): Promise { +export const buildAll = function ( + options: IDockerComposeBuildOptions = {} +): Promise { + return execCompose('build', options.parallel ? ['--parallel'] : [], options) +} + +export const buildMany = function ( + services: string[], + options: IDockerComposeBuildOptions = {} +): Promise { return execCompose( 'build', - options.parallel ? [ '--parallel' ] : [], + options.parallel ? ['--parallel'].concat(services) : services, options - ); -}; + ) +} -export const buildMany = function (services: string[], options: IDockerComposeBuildOptions = {}): Promise { - return execCompose( - 'build', - options.parallel ? [ '--parallel' ].concat(services) : services, - options - ); -}; +export const buildOne = function ( + service: string, + options?: IDockerComposeBuildOptions +): Promise { + return execCompose('build', [service], options) +} -export const buildOne = function (service: string, options?: IDockerComposeBuildOptions): Promise { - return execCompose('build', [ service ], options); -}; +export const pullAll = function ( + options: IDockerComposeOptions = {} +): Promise { + return execCompose('pull', [], options) +} -export const pullAll = function (options: IDockerComposeOptions = {}): Promise { - return execCompose('pull', [], options); -}; +export const pullMany = function ( + services: string[], + options: IDockerComposeOptions = {} +): Promise { + return execCompose('pull', services, options) +} -export const pullMany = function (services: string[], options: IDockerComposeOptions = {}): Promise { - return execCompose('pull', services, options); -}; +export const pullOne = function ( + service: string, + options?: IDockerComposeOptions +): Promise { + return execCompose('pull', [service], options) +} -export const pullOne = function (service: string, options?: IDockerComposeOptions): Promise { - return execCompose('pull', [ service ], options); -}; +export const config = function ( + options?: IDockerComposeOptions +): Promise { + return execCompose('config', [], options) +} -export const config = function (options?: IDockerComposeOptions): Promise { - return execCompose('config', [], options); -}; +export const configServices = function ( + options?: IDockerComposeOptions +): Promise { + return execCompose('config', ['--services'], options) +} -export const configServices = function (options?: IDockerComposeOptions): Promise { - return execCompose('config', [ '--services' ], options); -}; +export const configVolumes = function ( + options?: IDockerComposeOptions +): Promise { + return execCompose('config', ['--volumes'], options) +} -export const configVolumes = function (options?: IDockerComposeOptions): Promise { - return execCompose('config', [ '--volumes' ], options); -}; +export const ps = function ( + options?: IDockerComposeOptions +): Promise { + return execCompose('ps', [], options) +} -export const ps = function (options?: IDockerComposeOptions): Promise { - return execCompose('ps', [], options); -}; - -export const push = function (options: IDockerComposePushOptions = {}): Promise { +export const push = function ( + options: IDockerComposePushOptions = {} +): Promise { return execCompose( 'push', - options.ignorePushFailures ? [ '--ignore-push-failures' ] : [], + options.ignorePushFailures ? ['--ignore-push-failures'] : [], options - ); -}; + ) +} -export const restartAll = function (options?: IDockerComposeOptions): Promise { - return execCompose('restart', [], options); -}; +export const restartAll = function ( + options?: IDockerComposeOptions +): Promise { + return execCompose('restart', [], options) +} -export const restartMany = function (services: string[], options?: IDockerComposeOptions): Promise { - return execCompose('restart', services, options); -}; +export const restartMany = function ( + services: string[], + options?: IDockerComposeOptions +): Promise { + return execCompose('restart', services, options) +} -export const restartOne = function (service: string, options?: IDockerComposeOptions): Promise { - return restartMany([ service ], options); -}; +export const restartOne = function ( + service: string, + options?: IDockerComposeOptions +): Promise { + return restartMany([service], options) +} -export const logs = function (services: string | string[], options: IDockerComposeLogOptions = {}): Promise { - let args = Array.isArray(services) ? services : [ services ]; +export const logs = function ( + services: string | string[], + options: IDockerComposeLogOptions = {} +): Promise { + let args = Array.isArray(services) ? services : [services] if (options.follow) { - args = [ '--follow', ...args ]; + args = ['--follow', ...args] } - return execCompose('logs', args, options); -}; + return execCompose('logs', args, options) +} -export const port = function (service: string, containerPort: string | number, options?: IDockerComposeOptions): Promise { - const args = [ service, containerPort ]; +export const port = function ( + service: string, + containerPort: string | number, + options?: IDockerComposeOptions +): Promise { + const args = [service, containerPort] - return execCompose('port', args, options); -}; + return execCompose('port', args, options) +} -export const version = function (options?: IDockerComposeOptions): Promise { - return execCompose('version', [ '--short' ], options); -}; +export const version = function ( + options?: IDockerComposeOptions +): Promise { + return execCompose('version', ['--short'], options) +} diff --git a/test/index.test.ts b/test/index.test.ts index 820fe86..a7a39f0 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -1,578 +1,642 @@ -import Docker from 'dockerode'; -import * as compose from '../src/index'; -import * as path from 'path'; +import Docker from 'dockerode' +import * as compose from '../src/index' +import * as path from 'path' import { readFile } from 'fs' -const docker = new Docker(); +const docker = new Docker() // Docker commands, especially builds, can take some time. This makes sure that they can take the time they need. -jest.setTimeout(25000); +jest.setTimeout(25000) // Set to true if you need to diagnose using output -const logOutput = false; +const logOutput = false -const isContainerRunning = async (name: string): Promise => new Promise((resolve, reject): void => { - docker.listContainers((err, containers): void => { - if (err) { - reject(err); - } +const isContainerRunning = async (name: string): Promise => + new Promise((resolve, reject): void => { + docker.listContainers((err, containers): void => { + if (err) { + reject(err) + } - const running = (containers || []).filter((container): boolean => container.Names.includes(name)); + const running = (containers || []).filter((container): boolean => + container.Names.includes(name) + ) - resolve(running.length > 0); - }); -}); + resolve(running.length > 0) + }) + }) -const repoTags = (imageInfo): string[] => imageInfo.RepoTags || []; +const repoTags = (imageInfo): string[] => imageInfo.RepoTags || [] const imageExists = async (name: string): Promise => { - const images = await docker.listImages(); + const images = await docker.listImages() - const foundImage = images.findIndex((imageInfo): boolean => repoTags(imageInfo).includes(name)); + const foundImage = images.findIndex((imageInfo): boolean => + repoTags(imageInfo).includes(name) + ) - return foundImage > -1; -}; + return foundImage > -1 +} -const removeImagesStartingWith = async (searchString: string): Promise => { - const images = await docker.listImages(); +const removeImagesStartingWith = async ( + searchString: string +): Promise => { + const images = await docker.listImages() for (const image of images) { for (const repoTag of repoTags(image)) { if (repoTag.startsWith(searchString)) { - const dockerImage = docker.getImage(repoTag); + const dockerImage = docker.getImage(repoTag) if (logOutput) { - process.stdout.write(`removing image ${repoTag} ${dockerImage.id || ''}`); + process.stdout.write( + `removing image ${repoTag} ${dockerImage.id || ''}` + ) } - await dockerImage.remove(); + await dockerImage.remove() } } } -}; +} test('ensure container gets started', async (): Promise => { - await compose.down({ cwd: path.join(__dirname), log: logOutput }); - await compose.upAll({ cwd: path.join(__dirname), log: logOutput }); + await compose.down({ cwd: path.join(__dirname), log: logOutput }) + await compose.upAll({ cwd: path.join(__dirname), log: logOutput }) - expect(await isContainerRunning('/compose_test_web')).toBeTruthy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy(); - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + expect(await isContainerRunning('/compose_test_web')).toBeTruthy() + expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy() + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('ensure exit code is returned correctly', async (): Promise => { - let result = await compose.down({ cwd: path.join(__dirname), log: logOutput }); + let result = await compose.down({ cwd: path.join(__dirname), log: logOutput }) await expect(result).toMatchObject({ exitCode: 0 - }); + }) - result = await compose.upAll({ cwd: path.join(__dirname), log: logOutput }); + result = await compose.upAll({ cwd: path.join(__dirname), log: logOutput }) expect(result).toMatchObject({ exitCode: 0 - }); + }) try { - await compose.logs('non_existent_service', { cwd: path.join(__dirname) }); - expect(false).toBeTruthy(); + await compose.logs('non_existent_service', { cwd: path.join(__dirname) }) + expect(false).toBeTruthy() } catch (rejectionResult) { - expect(rejectionResult.exitCode).toBe(1); + expect(rejectionResult.exitCode).toBe(1) } - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) describe('starts containers properly with --build and --timeout options', (): void => { - beforeEach(async (): Promise => { - await compose.down({ cwd: path.join(__dirname), log: logOutput, config: 'docker-compose-build.yml' }); - }); + beforeEach( + async (): Promise => { + await compose.down({ + cwd: path.join(__dirname), + log: logOutput, + config: 'docker-compose-build.yml' + }) + } + ) - afterEach(async (): Promise => { - await compose.down({ cwd: path.join(__dirname), log: logOutput, config: 'docker-compose-build.yml' }); - }); + afterEach( + async (): Promise => { + await compose.down({ + cwd: path.join(__dirname), + log: logOutput, + config: 'docker-compose-build.yml' + }) + } + ) test('ensure container gets started with --build option', async (): Promise => { await compose.upAll({ cwd: path.join(__dirname), log: logOutput, config: 'docker-compose-build.yml', - commandOptions: [ '--build' ] - }); + commandOptions: ['--build'] + }) - expect(await isContainerRunning('/compose_test_nginx')).toBeTruthy(); - }); + expect(await isContainerRunning('/compose_test_nginx')).toBeTruthy() + }) test('ensure container gets started with --build and --timeout option', async (): Promise => { await compose.upAll({ cwd: path.join(__dirname), log: logOutput, config: 'docker-compose-build.yml', - commandOptions: [[ '--build' ], [ '--timeout', '5' ]] - }); + commandOptions: [['--build'], ['--timeout', '5']] + }) - expect(await isContainerRunning('/compose_test_nginx')).toBeTruthy(); - }); + expect(await isContainerRunning('/compose_test_nginx')).toBeTruthy() + }) test('ensure container gets started with --build and --timeout option with different command style', async (): Promise => { await compose.upAll({ cwd: path.join(__dirname), log: logOutput, config: 'docker-compose-build.yml', - commandOptions: [ '--build', [ '--timeout', '5' ]] - }); + commandOptions: ['--build', ['--timeout', '5']] + }) - expect(await isContainerRunning('/compose_test_nginx')).toBeTruthy(); - }); -}); + expect(await isContainerRunning('/compose_test_nginx')).toBeTruthy() + }) +}) test('ensure container command executed with --workdir command option', async (): Promise => { - await compose.down({ cwd: path.join(__dirname), log: logOutput, config: 'docker-compose-42.yml' }); + await compose.down({ + cwd: path.join(__dirname), + log: logOutput, + config: 'docker-compose-42.yml' + }) const result = await compose.run('some-service', 'pwd', { cwd: path.join(__dirname), log: true, config: 'docker-compose-42.yml', - composeOptions: [ '--verbose' ], + composeOptions: ['--verbose'], // Alpine has "/" as default - commandOptions: [ '--workdir', '/home/root' ] - }); + commandOptions: ['--workdir', '/home/root'] + }) - expect(result.out).toBe('/home/root\n'); + expect(result.out).toBe('/home/root\n') - await compose.down({ cwd: path.join(__dirname), log: logOutput, config: 'docker-compose-42.yml' }); -}); + await compose.down({ + cwd: path.join(__dirname), + log: logOutput, + config: 'docker-compose-42.yml' + }) +}) test('ensure only single container gets started', async (): Promise => { - await compose.down({ cwd: path.join(__dirname), log: logOutput }); - await compose.upOne('web', { cwd: path.join(__dirname), log: logOutput }); + await compose.down({ cwd: path.join(__dirname), log: logOutput }) + await compose.upOne('web', { cwd: path.join(__dirname), log: logOutput }) - expect(await isContainerRunning('/compose_test_web')).toBeTruthy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy(); - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + expect(await isContainerRunning('/compose_test_web')).toBeTruthy() + expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy() + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('ensure only multiple containers get started', async (): Promise => { - await compose.down({ cwd: path.join(__dirname), log: logOutput }); - await compose.upMany([ 'web' ], { cwd: path.join(__dirname), log: logOutput }); + await compose.down({ cwd: path.join(__dirname), log: logOutput }) + await compose.upMany(['web'], { cwd: path.join(__dirname), log: logOutput }) - expect(await isContainerRunning('/compose_test_web')).toBeTruthy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy(); - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + expect(await isContainerRunning('/compose_test_web')).toBeTruthy() + expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy() + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('ensure container gets down', async (): Promise => { - await compose.upAll({ cwd: path.join(__dirname), log: logOutput }); - expect(await isContainerRunning('/compose_test_web')).toBeTruthy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy(); + await compose.upAll({ cwd: path.join(__dirname), log: logOutput }) + expect(await isContainerRunning('/compose_test_web')).toBeTruthy() + expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy() - await compose.down({ cwd: path.join(__dirname), log: logOutput }); - expect(await isContainerRunning('/compose_test_web')).toBeFalsy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy(); -}); + await compose.down({ cwd: path.join(__dirname), log: logOutput }) + expect(await isContainerRunning('/compose_test_web')).toBeFalsy() + expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy() +}) test('ensure container gets stopped', async (): Promise => { - await compose.upAll({ cwd: path.join(__dirname), log: logOutput }); - expect(await isContainerRunning('/compose_test_web')).toBeTruthy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy(); + await compose.upAll({ cwd: path.join(__dirname), log: logOutput }) + expect(await isContainerRunning('/compose_test_web')).toBeTruthy() + expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy() - await compose.stop({ cwd: path.join(__dirname), log: logOutput }); - expect(await isContainerRunning('/compose_test_web')).toBeFalsy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy(); - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + await compose.stop({ cwd: path.join(__dirname), log: logOutput }) + expect(await isContainerRunning('/compose_test_web')).toBeFalsy() + expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy() + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('ensure only single container gets stopped', async (): Promise => { - await compose.upAll({ cwd: path.join(__dirname), log: logOutput }); - expect(await isContainerRunning('/compose_test_web')).toBeTruthy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy(); + await compose.upAll({ cwd: path.join(__dirname), log: logOutput }) + expect(await isContainerRunning('/compose_test_web')).toBeTruthy() + expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy() - await compose.stopOne('proxy', { cwd: path.join(__dirname), log: logOutput }); - expect(await isContainerRunning('/compose_test_web')).toBeTruthy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy(); - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + await compose.stopOne('proxy', { cwd: path.join(__dirname), log: logOutput }) + expect(await isContainerRunning('/compose_test_web')).toBeTruthy() + expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy() + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('ensure container gets started with --abort-on-container-exit option', async (): Promise => { const result = await compose.upAll({ cwd: path.join(__dirname), log: logOutput, - commandOptions: [ '--abort-on-container-exit' ] - }); + commandOptions: ['--abort-on-container-exit'] + }) expect(result).toMatchObject({ exitCode: 0 - }); + }) - expect(await isContainerRunning('/compose_test_web')).toBeFalsy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy(); - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + expect(await isContainerRunning('/compose_test_web')).toBeFalsy() + expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy() + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('ensure container gets started with --abort-on-container-exit option correctly aborts all services when a container exits', async (): Promise => { const result = await compose.upAll({ cwd: path.join(__dirname), log: logOutput, - commandOptions: [ '--abort-on-container-exit' ] - }); + commandOptions: ['--abort-on-container-exit'] + }) - expect(result.out).toMatch(/Aborting on container exit/); + expect(result.out).toMatch(/Aborting on container exit/) - expect(await isContainerRunning('/compose_test_web')).toBeFalsy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy(); - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + expect(await isContainerRunning('/compose_test_web')).toBeFalsy() + expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy() + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('ensure container gets killed', async (): Promise => { - await compose.upAll({ cwd: path.join(__dirname), log: logOutput }); - expect(await isContainerRunning('/compose_test_web')).toBeTruthy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy(); + await compose.upAll({ cwd: path.join(__dirname), log: logOutput }) + expect(await isContainerRunning('/compose_test_web')).toBeTruthy() + expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy() - await compose.kill({ cwd: path.join(__dirname), log: logOutput }); - expect(await isContainerRunning('/compose_test_web')).toBeFalsy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy(); + await compose.kill({ cwd: path.join(__dirname), log: logOutput }) + expect(await isContainerRunning('/compose_test_web')).toBeFalsy() + expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy() - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('ensure custom ymls are working', async (): Promise => { - const config = './docker-compose-2.yml'; - const cwd = path.join(__dirname); + const config = './docker-compose-2.yml' + const cwd = path.join(__dirname) - await compose.upAll({ cwd, log: logOutput, config }); - expect(await isContainerRunning('/compose_test_web_2')).toBeTruthy(); + await compose.upAll({ cwd, log: logOutput, config }) + expect(await isContainerRunning('/compose_test_web_2')).toBeTruthy() // config & [config] are the same thing, ensures that multiple configs are handled properly - await compose.kill({ cwd, log: logOutput, config: [ config ]}); - expect(await isContainerRunning('/compose_test_web_2')).toBeFalsy(); - - await compose.down({ cwd, log: logOutput, config }); -}); - + await compose.kill({ cwd, log: logOutput, config: [config] }) + expect(await isContainerRunning('/compose_test_web_2')).toBeFalsy() + await compose.down({ cwd, log: logOutput, config }) +}) test('ensure run and exec are working', async (): Promise => { const checkOSID = (out, id): void => { // parse /etc/os-release contents - const re = /([\w,_]+)=(.*)/g; - let match; - const os: {ID?: string} = {}; + const re = /([\w,_]+)=(.*)/g + let match + const os: { ID?: string } = {} - while ((match = re.exec(out)) !== null) { // eslint-disable-line no-cond-assign - os[match[1]] = match[2]; + while ((match = re.exec(out)) !== null) { + // eslint-disable-line no-cond-assign + os[match[1]] = match[2] } - expect(os.ID).toBe(id); - }; + expect(os.ID).toBe(id) + } - const opts = { cwd: path.join(__dirname), log: logOutput }; + const opts = { cwd: path.join(__dirname), log: logOutput } - await compose.upAll(opts); - const console = require('console'); - expect(await isContainerRunning('/compose_test_web')).toBeTruthy(); + await compose.upAll(opts) + const console = require('console') + expect(await isContainerRunning('/compose_test_web')).toBeTruthy() - let std = await compose.exec('web', 'cat /etc/os-release', opts); + let std = await compose.exec('web', 'cat /etc/os-release', opts) - checkOSID(std.out, 'debian'); + checkOSID(std.out, 'debian') - std = await compose.run('proxy', 'cat /etc/os-release', opts); - - checkOSID(std.out, 'alpine'); + std = await compose.run('proxy', 'cat /etc/os-release', opts) - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + checkOSID(std.out, 'alpine') + + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('ensure run and exec with command defined as array are working', async (): Promise => { const checkOSID = (out, id): void => { // parse /etc/os-release contents - const re = /([\w,_]+)=(.*)/g; - let match; - const os: {ID?: string} = {}; + const re = /([\w,_]+)=(.*)/g + let match + const os: { ID?: string } = {} - while ((match = re.exec(out)) !== null) { // eslint-disable-line no-cond-assign - os[match[1]] = match[2]; + while ((match = re.exec(out)) !== null) { + // eslint-disable-line no-cond-assign + os[match[1]] = match[2] } - expect(os.ID).toBe(id); - }; + expect(os.ID).toBe(id) + } - const opts = { cwd: path.join(__dirname), log: false }; + const opts = { cwd: path.join(__dirname), log: false } - await compose.upAll(opts); + await compose.upAll(opts) - expect(await isContainerRunning('/compose_test_web')).toBe(true); + expect(await isContainerRunning('/compose_test_web')).toBe(true) - let std = await compose.exec('web', [ '/bin/sh', '-c', 'cat /etc/os-release' ], opts); + let std = await compose.exec( + 'web', + ['/bin/sh', '-c', 'cat /etc/os-release'], + opts + ) - checkOSID(std.out, 'debian'); + checkOSID(std.out, 'debian') - std = await compose.run('proxy', [ '/bin/sh', '-c', 'cat /etc/os-release' ], opts); - checkOSID(std.out, 'alpine'); + std = await compose.run( + 'proxy', + ['/bin/sh', '-c', 'cat /etc/os-release'], + opts + ) + checkOSID(std.out, 'alpine') - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('build accepts config as string', async (): Promise => { - const configuration = await new Promise(function (resolve, reject): void { - readFile(path.join(__dirname, 'docker-compose-2.yml'), function (err, content) { - if (err) { - reject(err); - return; + const configuration = await new Promise(function ( + resolve, + reject + ): void { + readFile( + path.join(__dirname, 'docker-compose-2.yml'), + function (err, content) { + if (err) { + reject(err) + return + } + resolve(content.toString()) } - resolve(content.toString()); - }) - }); + ) + }) const config = { configAsString: configuration, - log: logOutput, - }; + log: logOutput + } - await compose.upAll(config); - const port = await compose.port('web', 8888, config); + await compose.upAll(config) + const port = await compose.port('web', 8888, config) - expect(port.out).toMatch(/.*:[0-9]{1,5}/); - await compose.down(config); -}); + expect(port.out).toMatch(/.*:[0-9]{1,5}/) + await compose.down(config) +}) test('build single service', async (): Promise => { const opts = { cwd: path.join(__dirname), log: logOutput, config: 'docker-compose-build.yml' - }; + } - await removeImagesStartingWith('compose-test-build-image'); + await removeImagesStartingWith('compose-test-build-image') - await compose.buildOne('build_test_1', opts); + await compose.buildOne('build_test_1', opts) - expect(await imageExists('compose-test-build-image-1:test')).toBeTruthy(); - expect(await imageExists('compose-test-build-image-2:test')).toBeFalsy(); - expect(await imageExists('compose-test-build-image-3:test')).toBeFalsy(); - expect(await imageExists('compose-test-build-image-4:test')).toBeFalsy(); + expect(await imageExists('compose-test-build-image-1:test')).toBeTruthy() + expect(await imageExists('compose-test-build-image-2:test')).toBeFalsy() + expect(await imageExists('compose-test-build-image-3:test')).toBeFalsy() + expect(await imageExists('compose-test-build-image-4:test')).toBeFalsy() - await removeImagesStartingWith('compose-test-build-image'); -}); + await removeImagesStartingWith('compose-test-build-image') +}) test('build multiple services', async (): Promise => { const opts = { cwd: path.join(__dirname), log: logOutput, config: 'docker-compose-build.yml' - }; + } - await compose.buildMany([ 'build_test_2', 'build_test_3' ], opts); + await compose.buildMany(['build_test_2', 'build_test_3'], opts) - expect(await imageExists('compose-test-build-image-1:test')).toBeFalsy(); - expect(await imageExists('compose-test-build-image-2:test')).toBeTruthy(); - expect(await imageExists('compose-test-build-image-3:test')).toBeTruthy(); - expect(await imageExists('compose-test-build-image-4:test')).toBeFalsy(); + expect(await imageExists('compose-test-build-image-1:test')).toBeFalsy() + expect(await imageExists('compose-test-build-image-2:test')).toBeTruthy() + expect(await imageExists('compose-test-build-image-3:test')).toBeTruthy() + expect(await imageExists('compose-test-build-image-4:test')).toBeFalsy() - await removeImagesStartingWith('compose-test-build-image'); -}); + await removeImagesStartingWith('compose-test-build-image') +}) test('build all services', async (): Promise => { const opts = { cwd: path.join(__dirname), log: logOutput, config: 'docker-compose-build.yml' - }; + } - await compose.buildAll(opts); + await compose.buildAll(opts) - expect(await imageExists('compose-test-build-image-1:test')).toBeTruthy(); - expect(await imageExists('compose-test-build-image-2:test')).toBeTruthy(); - expect(await imageExists('compose-test-build-image-3:test')).toBeTruthy(); - expect(await imageExists('compose-test-build-image-4:test')).toBeTruthy(); + expect(await imageExists('compose-test-build-image-1:test')).toBeTruthy() + expect(await imageExists('compose-test-build-image-2:test')).toBeTruthy() + expect(await imageExists('compose-test-build-image-3:test')).toBeTruthy() + expect(await imageExists('compose-test-build-image-4:test')).toBeTruthy() - await removeImagesStartingWith('compose-test-build-image'); -}); + await removeImagesStartingWith('compose-test-build-image') +}) test('pull single service', async (): Promise => { const opts = { cwd: path.join(__dirname), log: logOutput, config: 'docker-compose.yml' - }; + } - await removeImagesStartingWith('nginx:1.19.9-alpine'); - expect(await imageExists('nginx:1.19.9-alpine')).toBeFalsy(); + await removeImagesStartingWith('nginx:1.19.9-alpine') + expect(await imageExists('nginx:1.19.9-alpine')).toBeFalsy() - await compose.pullOne('proxy', opts); + await compose.pullOne('proxy', opts) - expect(await imageExists('nginx:1.19.9-alpine')).toBeTruthy(); -}); + expect(await imageExists('nginx:1.19.9-alpine')).toBeTruthy() +}) test('pull multiple services', async (): Promise => { const opts = { cwd: path.join(__dirname), log: logOutput, config: 'docker-compose.yml' - }; + } - await removeImagesStartingWith('nginx:1.16.0'); - await removeImagesStartingWith('nginx:1.19.9-alpine'); + await removeImagesStartingWith('nginx:1.16.0') + await removeImagesStartingWith('nginx:1.19.9-alpine') - expect(await imageExists('nginx:1.16.0')).toBeFalsy(); - expect(await imageExists('nginx:1.19.9-alpine')).toBeFalsy(); + expect(await imageExists('nginx:1.16.0')).toBeFalsy() + expect(await imageExists('nginx:1.19.9-alpine')).toBeFalsy() - await compose.pullMany([ 'web', 'proxy' ], opts); + await compose.pullMany(['web', 'proxy'], opts) - expect(await imageExists('nginx:1.16.0')).toBeTruthy(); - expect(await imageExists('nginx:1.19.9-alpine')).toBeTruthy(); -}); + expect(await imageExists('nginx:1.16.0')).toBeTruthy() + expect(await imageExists('nginx:1.19.9-alpine')).toBeTruthy() +}) test('pull all services', async (): Promise => { const opts = { cwd: path.join(__dirname), log: logOutput, config: 'docker-compose.yml' - }; + } - await removeImagesStartingWith('nginx:1.16.0'); - await removeImagesStartingWith('nginx:1.19.9-alpine'); + await removeImagesStartingWith('nginx:1.16.0') + await removeImagesStartingWith('nginx:1.19.9-alpine') - expect(await imageExists('nginx:1.16.0')).toBeFalsy(); - expect(await imageExists('nginx:1.19.9-alpine')).toBeFalsy(); + expect(await imageExists('nginx:1.16.0')).toBeFalsy() + expect(await imageExists('nginx:1.19.9-alpine')).toBeFalsy() - await compose.pullAll(opts); + await compose.pullAll(opts) - expect(await imageExists('nginx:1.16.0')).toBeTruthy(); - expect(await imageExists('nginx:1.19.9-alpine')).toBeTruthy(); -}); + expect(await imageExists('nginx:1.16.0')).toBeTruthy() + expect(await imageExists('nginx:1.19.9-alpine')).toBeTruthy() +}) test('teardown', async (): Promise => { interface Container { - Names: string[]; - Id: string; + Names: string[] + Id: string } docker.listContainers((err, containers: Container[]): void => { if (err) { - throw err; + throw err } containers.forEach((container): void => { container.Names.forEach((name: string): void => { if (name.startsWith('/compose_test_')) { - console.log(`stopping ${container.Id} ${container.Names}`); - docker.getContainer(container.Id).stop(); + console.log(`stopping ${container.Id} ${container.Names}`) + docker.getContainer(container.Id).stop() } - }); - }); - }); + }) + }) + }) - await removeImagesStartingWith('compose-test-build-image'); -}); + await removeImagesStartingWith('compose-test-build-image') +}) test('config show data for docker-compose files', async (): Promise => { - const std = await compose.config({ cwd: path.join(__dirname), log: logOutput, config: 'docker-compose-42.yml' }); + const std = await compose.config({ + cwd: path.join(__dirname), + log: logOutput, + config: 'docker-compose-42.yml' + }) - expect(std.err).toBeFalsy(); - expect(std.out.includes('some-service')).toBeTruthy(); - expect(std.out.includes('test/volume:/mountedvolume:rw')).toBeTruthy(); -}); + expect(std.err).toBeFalsy() + expect(std.out.includes('some-service')).toBeTruthy() + expect(std.out.includes('test/volume:/mountedvolume:rw')).toBeTruthy() +}) test('config show data for docker-compose files (services)', async (): Promise => { - const std = await compose.configServices({ cwd: path.join(__dirname), log: logOutput, config: 'docker-compose-42.yml' }); + const std = await compose.configServices({ + cwd: path.join(__dirname), + log: logOutput, + config: 'docker-compose-42.yml' + }) - expect(std.err).toBeFalsy(); - expect(std.out.includes('some-service')).toBeTruthy(); -}); + expect(std.err).toBeFalsy() + expect(std.out.includes('some-service')).toBeTruthy() +}) test('config show data for docker-compose files (volumes)', async (): Promise => { - const std = await compose.configVolumes({ cwd: path.join(__dirname), log: logOutput, config: 'docker-compose-42.yml' }); + const std = await compose.configVolumes({ + cwd: path.join(__dirname), + log: logOutput, + config: 'docker-compose-42.yml' + }) - expect(std.err).toBeFalsy(); - expect(std.out.includes('db-data')).toBeTruthy(); -}); + expect(std.err).toBeFalsy() + expect(std.out.includes('db-data')).toBeTruthy() +}) test('ps shows status data for started containers', async (): Promise => { - await compose.upAll({ cwd: path.join(__dirname), log: logOutput }); + await compose.upAll({ cwd: path.join(__dirname), log: logOutput }) - const std = await compose.ps({ cwd: path.join(__dirname), log: logOutput }); + const std = await compose.ps({ cwd: path.join(__dirname), log: logOutput }) - expect(std.err).toBeFalsy(); - expect(std.out.includes('compose_test_web')).toBeTruthy(); - expect(std.out.includes('compose_test_proxy')).toBeTruthy(); - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + expect(std.err).toBeFalsy() + expect(std.out.includes('compose_test_web')).toBeTruthy() + expect(std.out.includes('compose_test_proxy')).toBeTruthy() + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('ps does not show status data for stopped containers', async (): Promise => { - await compose.down({ cwd: path.join(__dirname), log: logOutput }); - await compose.upOne('web', { cwd: path.join(__dirname), log: logOutput }); + await compose.down({ cwd: path.join(__dirname), log: logOutput }) + await compose.upOne('web', { cwd: path.join(__dirname), log: logOutput }) - const std = await compose.ps({ cwd: path.join(__dirname), log: logOutput }); + const std = await compose.ps({ cwd: path.join(__dirname), log: logOutput }) - expect(std.err).toBeFalsy(); - expect(std.out.includes('compose_test_web')).toBeTruthy(); - expect(std.out.includes('compose_test_proxy')).toBeFalsy(); - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + expect(std.err).toBeFalsy() + expect(std.out.includes('compose_test_web')).toBeTruthy() + expect(std.out.includes('compose_test_proxy')).toBeFalsy() + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('restartAll does restart all containers', async (): Promise => { - await compose.upAll({ cwd: path.join(__dirname), log: logOutput }); - await compose.restartAll({ cwd: path.join(__dirname), log: logOutput }); + await compose.upAll({ cwd: path.join(__dirname), log: logOutput }) + await compose.restartAll({ cwd: path.join(__dirname), log: logOutput }) - expect(await isContainerRunning('/compose_test_web')).toBeTruthy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy(); - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + expect(await isContainerRunning('/compose_test_web')).toBeTruthy() + expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy() + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('restartMany does restart selected containers', async (): Promise => { - await compose.upAll({ cwd: path.join(__dirname), log: logOutput }); - await compose.restartMany([ 'web', 'proxy' ], { cwd: path.join(__dirname), log: logOutput }); + await compose.upAll({ cwd: path.join(__dirname), log: logOutput }) + await compose.restartMany(['web', 'proxy'], { + cwd: path.join(__dirname), + log: logOutput + }) - expect(await isContainerRunning('/compose_test_web')).toBeTruthy(); - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + expect(await isContainerRunning('/compose_test_web')).toBeTruthy() + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('restartOne does restart container', async (): Promise => { - await compose.upAll({ cwd: path.join(__dirname), log: logOutput }); - await compose.restartOne('proxy', { cwd: path.join(__dirname), log: logOutput }); + await compose.upAll({ cwd: path.join(__dirname), log: logOutput }) + await compose.restartOne('proxy', { + cwd: path.join(__dirname), + log: logOutput + }) - expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy(); - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy() + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('logs does follow service logs', async (): Promise => { - await compose.upAll({ cwd: path.join(__dirname), log: logOutput }); - const std = await compose.logs('proxy', { cwd: path.join(__dirname), log: logOutput }); + await compose.upAll({ cwd: path.join(__dirname), log: logOutput }) + const std = await compose.logs('proxy', { + cwd: path.join(__dirname), + log: logOutput + }) - expect(std.out.includes('compose_test_proxy')).toBeTruthy(); - await compose.down({ cwd: path.join(__dirname), log: logOutput }); -}); + expect(std.out.includes('compose_test_proxy')).toBeTruthy() + await compose.down({ cwd: path.join(__dirname), log: logOutput }) +}) test('returns the port for a started service', async (): Promise => { const config = { cwd: path.join(__dirname), config: './docker-compose-2.yml', log: logOutput - }; + } - await compose.upAll(config); - const port = await compose.port('web', 8888, config); + await compose.upAll(config) + const port = await compose.port('web', 8888, config) - expect(port.out).toMatch(/.*:[0-9]{1,5}/); - await compose.down(config); -}); + expect(port.out).toMatch(/.*:[0-9]{1,5}/) + await compose.down(config) +}) test('removes container', async (): Promise => { const config = { cwd: path.join(__dirname), config: './docker-compose.yml', log: logOutput - }; + } - await compose.upAll(config); - expect(await isContainerRunning('/compose_test_web')).toBeTruthy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy(); + await compose.upAll(config) + expect(await isContainerRunning('/compose_test_web')).toBeTruthy() + expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy() - await compose.rm({ ...config, commandOptions: ['-s'] }, 'proxy'); - expect(await isContainerRunning('/compose_test_web')).toBeTruthy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy(); + await compose.rm({ ...config, commandOptions: ['-s'] }, 'proxy') + expect(await isContainerRunning('/compose_test_web')).toBeTruthy() + expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy() - await compose.rm({ ...config, commandOptions: ['-s'] }, 'proxy', 'web'); - expect(await isContainerRunning('/compose_test_web')).toBeFalsy(); - expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy(); -}); + await compose.rm({ ...config, commandOptions: ['-s'] }, 'proxy', 'web') + expect(await isContainerRunning('/compose_test_web')).toBeFalsy() + expect(await isContainerRunning('/compose_test_proxy')).toBeFalsy() +}) test('returns version information', async (): Promise => { - const version = await compose.version(); + const version = await compose.version() - expect(version.out).toBeTruthy(); -}); + expect(version.out).toBeTruthy() +})