-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(env): setup testing environment with jest and docker
setup jest configurations and jest-setup to work with typescript setup docker-compose to spin up required dependencies such as database and a node container to run the tests in setup some example tests that use transactions setup postgres to automatically start with the schema provided
- Loading branch information
1 parent
f611450
commit 3b9c81d
Showing
14 changed files
with
10,859 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
version: '3.8' | ||
services: | ||
api: | ||
container_name: hpc_api | ||
build: | ||
context: . | ||
dockerfile: ./env/api/Dockerfile | ||
volumes: | ||
- .:/srv/www | ||
environment: | ||
- POSTGRES_CONNECTION_STRING=postgres://postgres:demo@db:5432/demo | ||
- NODE_ENV=development | ||
- WAIT_HOSTS=db:5432 | ||
- WAIT_HOSTS_TIMEOUT=120 | ||
links: | ||
- db | ||
depends_on: | ||
- db | ||
db: | ||
image: postgres:11.7 | ||
container_name: hpc_postgres_db | ||
environment: | ||
- POSTGRES_PASSWORD=demo | ||
- POSTGRES_USER=postgres | ||
- POSTGRES_DB=demo | ||
ports: | ||
- 5432:5432 | ||
volumes: | ||
- ./env/db/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM unocha/nodejs:12 | ||
|
||
RUN apk add -U build-base python3 py-pip | ||
|
||
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait | ||
RUN chmod +x /wait | ||
|
||
RUN rm -rf /etc/services.d/node | ||
|
||
COPY ./env/api/node.sh /node.sh | ||
RUN chmod +x /node.sh | ||
|
||
CMD /node.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/with-contenv sh | ||
|
||
cd "$NODE_APP_DIR" | ||
|
||
if [ ! -d "node_modules" ]; then | ||
echo "==> Installing npm dependencies" | ||
npm install | ||
fi | ||
|
||
echo "==> Waiting for postgres to start" | ||
/wait | ||
|
||
echo "==> Starting the tests" | ||
npm run test |
Oops, something went wrong.