Fix up jest and mock prisma #7
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: Run Jest Tests | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
test-api: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./api | |
services: | |
postgres: | |
image: postgres:14 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: testing | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: npm install | |
- name: Generate Prisma Client | |
run: npx prisma generate | |
- name: Run Prisma Migrations | |
run: npx prisma migrate deploy | |
env: | |
DATABASE_URL: 'postgresql://postgres:postgres@localhost:5432/testing?schema=public' | |
- name: Run Jest tests | |
run: npm test | |
env: | |
DATABASE_URL: 'postgresql://postgres:postgres@localhost:5432/testing?schema=public' |