This package allows to run tests that use docker-compose and supports multi-stage setup.
This runner creates docker-compose services in stopped state and then starts them accordingly to the stages. It will start the new stage only when all the services on current one will be running. When all the stages are done the actual Jest tests will be run. After the tests will be completed the services will be teared down.
- Run 
npm install --save-dev docker-compose-jest-runner - Add 
dc-jest-runner.ymlto the root repo or useDC_JEST_RUNNER_CONFIGenvironment variable for path to the config file. - Add 
runner:docker-compose-jest-runnertojest.config.jsfile. 
That's all
  files: string | string[] (optional, default 'docker-compose.yaml') # docker-compose yaml files
  skipPull: boolean (optional, default false) # skips pulling docker images
  skipBuild: boolean (optional, default false) # skips building docker images
  timeout: number (optional, default Infinity) # maximum time in ms to wait for service on each stage
  interval: number (optional, default 250) # interval to check service in ms
  stages:
    - name: string
      services:
        - name: string # should be exactly as in docker-compose files
          timeout: number (optional, defaults to stage's value)
          interval: number (optional, defaults to stage's value)
          logs: boolean (optional, default false) # if "true" prints the container logs after tests execution
          check: string or object # based on `wait-on` npm package
            protocol: tcp | http | https | http-get | https-get
            port: number (optional, default 80 for http and 443 for https)
            path: stringLook here for more details regarding service check definition.
files:
  - ./tests/docker-compose.yml
timeout: 2000
interval: 100
stages:
  - name: Infra
    services:
      - name: mongo
        check: 'tcp:localhost:27017'
  - name: Service
    services:
      - name: api
        logs: true
        check:
          port: 3000
          protocol: http-get
          path: /posts
- 
Clone the repo:
git clone git@github.com:AleF83/docker-compose-jest-runner.git
 - 
Install
npmpackages:npm ci
 - 
Build the project:
npm run build
 - 
Run tests:
npm run test