Skip to content

Commit dbcf909

Browse files
committed
Add code
1 parent 2b50e40 commit dbcf909

File tree

14 files changed

+7301
-0
lines changed

14 files changed

+7301
-0
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build
2+
node_modules

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# docker-compose-jest-runner
2+
3+
This package allows to run tests that use `docker-compose` and supports multi-stage setup.
4+
5+
## Setup
6+
7+
1. Run `npm install --save-dev docker-compose-jest-runner`
8+
2. Add `dc-jest-runner.yml` to the root repo or use `DC_JEST_RUNNER_CONFIG` environment variable for path to the config file.
9+
3. Add `runner`: `docker-compose-jest-runner` to `jest.config.js` file.
10+
11+
That's all
12+
13+
## Configuration
14+
15+
```yaml
16+
files: string | string[] (optional, default 'docker-compose.yaml') # docker-compose yaml files
17+
skipPull: boolean (optional, default false) # skips pulling docker images
18+
skipBuild: boolean (optional, default false) # skips building docker images
19+
timeout: number (optional, default Infinity) # maximum time in ms to wait for service on each stage
20+
interval: number (optional, default 250) # interval to check service in ms
21+
stages:
22+
- name: string
23+
services:
24+
- name: string # should be exactly as in docker-compose files
25+
timeout: number (optional, defaults to stage's value)
26+
interval: number (optional, defaults to stage's value)
27+
logs: boolean (optional, default false) # if "true" prints the container logs after tests execution
28+
check: string or object # based on `wait-on` npm package
29+
protocol: tcp | http | https | http-get | https-get
30+
port: number (optional, default 80 for http and 443 for https)
31+
path: string
32+
```
33+
34+
Look [here](https://github.com/jeffbski/wait-on#usage) for more details regarding service check definition.
35+
36+
## Example
37+
38+
```yaml
39+
files:
40+
- ./tests/docker-compose.yml
41+
timeout: 2000
42+
interval: 100
43+
stages:
44+
- name: Infra
45+
services:
46+
- name: mongo
47+
check: 'tcp:localhost:27017'
48+
- name: Service
49+
services:
50+
- name: api
51+
logs: true
52+
check:
53+
port: 3000
54+
protocol: http-get
55+
path: /posts
56+
57+
```
58+
59+
## Contributing
60+
61+
### Requirements
62+
63+
1. [Docker](https://www.docker.com/)
64+
65+
2. [NodeJS](https://nodejs.org/en/)
66+
67+
### Getting started
68+
69+
1. Clone the repo:
70+
71+
```sh
72+
git clone git@github.com:AleF83/docker-compose-jest-runner.git
73+
```
74+
75+
2. Install `npm` packages:
76+
77+
```sh
78+
npm ci
79+
```
80+
81+
3. Build the project:
82+
83+
```sh
84+
npm run build
85+
```
86+
87+
4. Run tests:
88+
89+
```sh
90+
npm run test
91+
```

0 commit comments

Comments
 (0)