WIP
This commit is contained in:
30
backend/tests/setup.js
Normal file
30
backend/tests/setup.js
Normal file
@ -0,0 +1,30 @@
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.join(__dirname, '../.env') });
|
||||
|
||||
// Set test environment variables
|
||||
process.env.NODE_ENV = 'test';
|
||||
process.env.JWT_SECRET = 'test-jwt-secret-key-for-testing-only';
|
||||
process.env.DB_NAME = 'bookmark_manager_test';
|
||||
|
||||
// Mock email service to prevent actual emails during tests
|
||||
jest.mock('../src/services/EmailService', () => ({
|
||||
sendVerificationEmail: jest.fn().mockResolvedValue({ message: 'Email sent' }),
|
||||
sendPasswordResetEmail: jest.fn().mockResolvedValue({ message: 'Email sent' })
|
||||
}));
|
||||
|
||||
// Mock console methods to reduce noise during tests
|
||||
const originalConsoleLog = console.log;
|
||||
const originalConsoleError = console.error;
|
||||
|
||||
beforeAll(() => {
|
||||
console.log = jest.fn();
|
||||
console.error = jest.fn();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
console.log = originalConsoleLog;
|
||||
console.error = originalConsoleError;
|
||||
});
|
||||
|
||||
// Global test timeout
|
||||
jest.setTimeout(10000);
|
||||
Reference in New Issue
Block a user