Skip to content

Commit

Permalink
workflows: Add mongodb server to jest workflow for database tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
kuv2707 committed Jun 8, 2024
1 parent dec586d commit 412c3b7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/jest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
with:
node-version: '20'

- name: Use MongoDB in Github Actions
uses: supercharge/[email protected]


- name: Install backend dependencies
working-directory: ./backend
run: npm install
Expand Down
13 changes: 13 additions & 0 deletions backend/tests/database.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import mongoose from 'mongoose';

describe('DB connection test', () => {
beforeAll(async () => {
await mongoose
.connect('mongodb://localhost:27017/testdb')
.then(() => console.log('DB connected'));
});

afterAll(async () => {
await mongoose.connection.close();
});
});

0 comments on commit 412c3b7

Please sign in to comment.