fix: suppress all console.error noise in API tests
Some checks failed
Basil CI/CD Pipeline / Code Linting (push) Successful in 1m0s
Basil CI/CD Pipeline / Web Tests (push) Failing after 1m11s
Basil CI/CD Pipeline / API Tests (push) Failing after 1m19s
Basil CI/CD Pipeline / Shared Package Tests (push) Successful in 57s
Basil CI/CD Pipeline / Security Scanning (push) Successful in 1m7s
Basil CI/CD Pipeline / Build All Packages (push) Has been skipped
Basil CI/CD Pipeline / E2E Tests (push) Has been skipped
Basil CI/CD Pipeline / Build & Push Docker Images (push) Has been skipped
Basil CI/CD Pipeline / Trigger Deployment (push) Has been skipped
Some checks failed
Basil CI/CD Pipeline / Code Linting (push) Successful in 1m0s
Basil CI/CD Pipeline / Web Tests (push) Failing after 1m11s
Basil CI/CD Pipeline / API Tests (push) Failing after 1m19s
Basil CI/CD Pipeline / Shared Package Tests (push) Successful in 57s
Basil CI/CD Pipeline / Security Scanning (push) Successful in 1m7s
Basil CI/CD Pipeline / Build All Packages (push) Has been skipped
Basil CI/CD Pipeline / E2E Tests (push) Has been skipped
Basil CI/CD Pipeline / Build & Push Docker Images (push) Has been skipped
Basil CI/CD Pipeline / Trigger Deployment (push) Has been skipped
- Remove email service mock from meal-plans.routes.real.test.ts (was breaking registration) - Add console.error suppression to meal-plans.routes.real.test.ts - Add console.error suppression to recipes.routes.real.test.ts - Add console.error suppression to cookbooks.routes.test.ts - Add console.error suppression to tags.routes.test.ts - Add console.error suppression to storage.service.test.ts All intentional error tests now run without stderr noise in CI
This commit is contained in:
@@ -36,16 +36,21 @@ vi.mock('../config/database', () => ({
|
|||||||
|
|
||||||
describe('Cookbooks Routes - Unit Tests', () => {
|
describe('Cookbooks Routes - Unit Tests', () => {
|
||||||
let app: express.Application;
|
let app: express.Application;
|
||||||
|
let consoleErrorSpy: any;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
app = express();
|
app = express();
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use('/cookbooks', cookbooksRouter);
|
app.use('/cookbooks', cookbooksRouter);
|
||||||
|
// Suppress console.error to avoid noise from intentional error tests
|
||||||
|
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
|
// Restore console.error
|
||||||
|
consoleErrorSpy?.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('GET /cookbooks', () => {
|
describe('GET /cookbooks', () => {
|
||||||
|
|||||||
@@ -3,18 +3,15 @@ import request from 'supertest';
|
|||||||
import app from '../index';
|
import app from '../index';
|
||||||
import prisma from '../config/database';
|
import prisma from '../config/database';
|
||||||
|
|
||||||
// Mock email service to prevent actual email sending in tests
|
|
||||||
vi.mock('../services/email.service', () => ({
|
|
||||||
sendVerificationEmail: vi.fn().mockResolvedValue(undefined),
|
|
||||||
sendPasswordResetEmail: vi.fn().mockResolvedValue(undefined),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('Meal Plans Routes - Real Integration Tests', () => {
|
describe('Meal Plans Routes - Real Integration Tests', () => {
|
||||||
let authToken: string;
|
let authToken: string;
|
||||||
let testUserId: string;
|
let testUserId: string;
|
||||||
let testRecipeId: string;
|
let testRecipeId: string;
|
||||||
|
let consoleErrorSpy: any;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
// Suppress console.error to avoid noise from email sending failures
|
||||||
|
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
// Create test user and get auth token
|
// Create test user and get auth token
|
||||||
const userResponse = await request(app)
|
const userResponse = await request(app)
|
||||||
.post('/api/auth/register')
|
.post('/api/auth/register')
|
||||||
@@ -66,6 +63,9 @@ describe('Meal Plans Routes - Real Integration Tests', () => {
|
|||||||
if (testUserId) {
|
if (testUserId) {
|
||||||
await prisma.user.delete({ where: { id: testUserId } });
|
await prisma.user.delete({ where: { id: testUserId } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restore console.error
|
||||||
|
consoleErrorSpy?.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
|||||||
@@ -75,12 +75,20 @@ import prisma from '../config/database';
|
|||||||
|
|
||||||
describe('Recipes Routes - Real Integration Tests', () => {
|
describe('Recipes Routes - Real Integration Tests', () => {
|
||||||
let app: Express;
|
let app: Express;
|
||||||
|
let consoleErrorSpy: any;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
app = express();
|
app = express();
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use('/api/recipes', recipesRoutes);
|
app.use('/api/recipes', recipesRoutes);
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
|
// Suppress console.error to avoid noise from intentional error tests
|
||||||
|
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
// Restore console.error
|
||||||
|
consoleErrorSpy?.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('GET /api/recipes', () => {
|
describe('GET /api/recipes', () => {
|
||||||
|
|||||||
@@ -18,16 +18,21 @@ vi.mock('../config/database', () => ({
|
|||||||
|
|
||||||
describe('Tags Routes - Unit Tests', () => {
|
describe('Tags Routes - Unit Tests', () => {
|
||||||
let app: express.Application;
|
let app: express.Application;
|
||||||
|
let consoleErrorSpy: any;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
app = express();
|
app = express();
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use('/tags', tagsRouter);
|
app.use('/tags', tagsRouter);
|
||||||
|
// Suppress console.error to avoid noise from intentional error tests
|
||||||
|
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
|
// Restore console.error
|
||||||
|
consoleErrorSpy?.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('GET /tags', () => {
|
describe('GET /tags', () => {
|
||||||
|
|||||||
@@ -14,14 +14,19 @@ vi.mock('../config/storage', () => ({
|
|||||||
|
|
||||||
describe('StorageService', () => {
|
describe('StorageService', () => {
|
||||||
let storageService: StorageService;
|
let storageService: StorageService;
|
||||||
|
let consoleErrorSpy: any;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
storageService = StorageService.getInstance();
|
storageService = StorageService.getInstance();
|
||||||
|
// Suppress console.error to avoid noise from intentional error tests
|
||||||
|
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
|
// Restore console.error
|
||||||
|
consoleErrorSpy?.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getInstance', () => {
|
describe('getInstance', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user