Skip to content

Commit bab7655

Browse files
committed
fix: ci env mismatch and mock email service for tests
1 parent 9ccffa9 commit bab7655

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ jobs:
2424
- name: Run Jest Tests
2525
run: cd backend && npm test
2626
env:
27-
MONGO_URL: ${{ secrets.MONGO_URL_TEST }} # Mock or Test DB
27+
NODE_ENV: test
28+
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
29+
TEST_MONGO_URL: ${{ secrets.MONGO_URL_TEST }}
2830
JWT_SECRET: ${{ secrets.JWT_SECRET }}
2931

3032
frontend-lint:

backend/tests/auth.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
const request = require('supertest');
22
const mongoose = require('mongoose');
3+
4+
jest.mock('resend', () => {
5+
return {
6+
Resend: jest.fn().mockImplementation(() => ({
7+
emails: {
8+
send: jest.fn().mockResolvedValue({ data: { id: 'mock_id' }, error: null }),
9+
},
10+
})),
11+
};
12+
});
13+
314
const app = require('../app');
415
const Developer = require('../models/Developer');
516
const bcrypt = require('bcryptjs');
617
require('dotenv').config();
718

19+
20+
821
// --- SETUP
922
beforeAll(async () => {
1023
// Connect to the TEST Database

backend/utils/emailService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { Resend } = require('resend');
33
const dotenv = require('dotenv');
44

55
dotenv.config();
6-
const resend = new Resend(process.env.RESEND_API_KEY);
6+
const resend = new Resend(process.env.RESEND_API_KEY || 're_dummy_key_for_testing');
77

88
async function sendOtp(email, otp) {
99
try {

0 commit comments

Comments
 (0)