Added Cypress tests #1
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
name: Auto Test Election creation and Voting system | |
on: push | |
env: | |
PG_DATABASE: wd-todo-test | |
PG_USER: postgres | |
PG_PASSWORD: postgres | |
jobs: | |
# Label of the container job | |
run-tests: | |
# Containers must run in Linux based operating systems | |
runs-on: ubuntu-latest | |
# Service containers to run with `container-job` | |
services: | |
# Label used to access the service container | |
postgres: | |
# Docker Hub image | |
image: postgres:15.2 | |
# Provide the password for postgres | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: wd-todo-test | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
# Downloads a copy of the code in your repository before running CI tests | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
# Performs a clean installation of all dependencies in the `package.json` file | |
# For more information, see https://docs.npmjs.com/cli/ci.html | |
- name: Install dependencies | |
run: npm ci | |
- name: Run unit tests | |
run: npm test | |
- name: Run the app | |
id: run-app | |
run: | | |
npm install | |
npx sequelize-cli db:drop | |
npx sequelize-cli db:create | |
npx sequelize-cli db:migrate | |
PORT=3000 npm start & | |
sleep 5 | |
- name: Run integration tests | |
run: | | |
npm install cypress cypress-json-results | |
npx cypress run |