Skip to content

Commit

Permalink
unit-tests fix (copy utils in build.yml)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelalvaigle committed Nov 28, 2024
1 parent 22f808f commit c23f706
Show file tree
Hide file tree
Showing 6 changed files with 1,563 additions and 393 deletions.
43 changes: 24 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,27 @@ jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm --prefix users/authservice ci
- run: npm --prefix users/userservice ci
- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
# Copiar utils a cada servicio si es necesario
- run: cp -R utils/ users/authservice/
- run: cp -R utils/ users/userservice/
# Instalar dependencias
- run: npm --prefix users/authservice ci
- run: npm --prefix users/userservice ci
- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
# Ejecutar tests
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
12 changes: 6 additions & 6 deletions gatewayservice/gateway-service.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const request = require('supertest');
const axios = require('axios');
const app = require('./gateway-service');
import request from 'supertest';
import axios from 'axios';
const app = (await import('./gateway-service.js')).default;

afterAll(async () => {
app.close();
});
app.close();
});

jest.mock('axios');

Expand Down Expand Up @@ -37,4 +37,4 @@ describe('Gateway Service', () => {
expect(response.statusCode).toBe(200);
expect(response.body.userId).toBe('mockedUserId');
});
});
});
Loading

0 comments on commit c23f706

Please sign in to comment.