fix: suppress console.error in error-testing scenarios
Some checks failed
Basil CI/CD Pipeline / Code Linting (push) Successful in 1m0s
Basil CI/CD Pipeline / Web Tests (push) Failing after 1m14s
Basil CI/CD Pipeline / Shared Package Tests (push) Successful in 57s
Basil CI/CD Pipeline / Security Scanning (push) Successful in 1m8s
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
Basil CI/CD Pipeline / API Tests (push) Failing after 1m21s
Test Harbor Secrets / Test Harbor Secret Access (push) Successful in 5s
Basil CI/CD Pipeline / Build All Packages (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 1m14s
Basil CI/CD Pipeline / Shared Package Tests (push) Successful in 57s
Basil CI/CD Pipeline / Security Scanning (push) Successful in 1m8s
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
Basil CI/CD Pipeline / API Tests (push) Failing after 1m21s
Test Harbor Secrets / Test Harbor Secret Access (push) Successful in 5s
Basil CI/CD Pipeline / Build All Packages (push) Has been skipped
- Add console.error mocking to cookbooks.routes.real.test.ts - Re-enable meal-plans.routes.test.ts with console.error suppression - These tests intentionally trigger errors to test error handling - Suppressing console.error prevents noise in CI output while tests still validate behavior Fixes stderr noise in pipeline from intentional error tests
This commit is contained in:
@@ -53,12 +53,20 @@ import prisma from '../config/database';
|
|||||||
|
|
||||||
describe('Cookbooks Routes - Real Integration Tests', () => {
|
describe('Cookbooks 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/cookbooks', cookbooksRoutes);
|
app.use('/api/cookbooks', cookbooksRoutes);
|
||||||
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/cookbooks', () => {
|
describe('GET /api/cookbooks', () => {
|
||||||
|
|||||||
@@ -42,12 +42,20 @@ vi.mock('../middleware/auth.middleware', () => ({
|
|||||||
|
|
||||||
describe('Meal Plans Routes - Unit Tests', () => {
|
describe('Meal Plans 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('/meal-plans', mealPlansRouter);
|
app.use('/meal-plans', mealPlansRouter);
|
||||||
|
// Suppress console.error to avoid noise from intentional error tests
|
||||||
|
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
// Restore console.error
|
||||||
|
consoleErrorSpy?.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('GET /meal-plans', () => {
|
describe('GET /meal-plans', () => {
|
||||||
Reference in New Issue
Block a user