diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5834b12..e5b8117 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 diff --git a/questionservice/question-service.test.js b/questionservice/question-service.test.js index b549c73..d07ef33 100644 --- a/questionservice/question-service.test.js +++ b/questionservice/question-service.test.js @@ -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;