Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/os-guild/docker-compose-jest-runner
This package allows to run tests that use docker-compose and supports multi-stage setup.
https://github.com/os-guild/docker-compose-jest-runner
Last synced: about 1 month ago
JSON representation
This package allows to run tests that use docker-compose and supports multi-stage setup.
- Host: GitHub
- URL: https://github.com/os-guild/docker-compose-jest-runner
- Owner: OS-Guild
- License: mit
- Created: 2021-12-01T12:32:48.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-09-12T12:16:28.000Z (over 2 years ago)
- Last Synced: 2024-03-26T06:26:29.731Z (9 months ago)
- Language: TypeScript
- Size: 79.1 KB
- Stars: 28
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# docker-compose-jest-runner
This package allows to run tests that use `docker-compose` and supports multi-stage setup.
## How it works?
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.
## Setup
1. Run `npm install --save-dev docker-compose-jest-runner`
2. Add `dc-jest-runner.yml` to the root repo or use `DC_JEST_RUNNER_CONFIG` environment variable for path to the config file.
3. Add `runner`: `docker-compose-jest-runner` to `jest.config.js` file.That's all
## Configuration
```yaml
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: string
```Look [here](https://github.com/jeffbski/wait-on#usage) for more details regarding service check definition.
## Example
```yaml
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```
## Contributing
### Requirements
1. [Docker](https://www.docker.com/)
2. [NodeJS](https://nodejs.org/en/)
### Getting started
1. Clone the repo:
```sh
git clone [email protected]:AleF83/docker-compose-jest-runner.git
```2. Install `npm` packages:
```sh
npm ci
```3. Build the project:
```sh
npm run build
```4. Run tests:
```sh
npm run test
```