Skip to content

Commit

Permalink
question-service test fix (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelalvaigle committed Dec 2, 2024
1 parent 9655834 commit 68169f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- run: cp -R errors/ questionservice/
- run: cp -R middleware/ questionservice/
- run: cp -R utils/ questionservice/
- run: cp -R errors/ statservice/
#- run: cp -R errors/ statservice/
- run: cp -R middleware/ statservice/
#- run: cp -R utils/ statservice/
# Instalar dependencias
Expand All @@ -33,7 +33,7 @@ jobs:
# Ejecutar tests
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
# - run: npm --prefix questionservice test -- --coverage
- run: npm --prefix questionservice test -- --coverage
- run: npm --prefix statservice test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
Expand Down
10 changes: 9 additions & 1 deletion questionservice/question-service.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import request from 'supertest';
import { MongoMemoryServer } from 'mongodb-memory-server';
import Question from './question-model.js';
import { jest } from '@jest/globals'; // Importa jest desde @jest/globals

// Sobrescribe `authenticateUser` antes de importar el servicio
jest.unstable_mockModule('./middleware/auth-middleware', () => ({
authenticateUser: jest.fn((req, res, next) => {
req.user = { userId: '507f1f77bcf86cd799439011', role: 'user' };
next();
}),
}));

let mongoServer;
let app;
Expand Down

0 comments on commit 68169f6

Please sign in to comment.