refactor(nestjs): e2e test cases

This commit is contained in:
Ahmed Bouhuolia
2025-04-07 00:09:58 +02:00
parent 842a862b87
commit f068218a16
25 changed files with 242 additions and 32 deletions

View File

@@ -1,12 +1,16 @@
import * as request from 'supertest';
import { INestApplication, Logger } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { AppModule } from '../src/modules/App/App.module';
let app: INestApplication;
let orgainzationId = 'hpgpqhanm8s4921m';
let authenticationToken =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZXhwIjoxNzQ4MzExOTc5LjIzOCwiaWF0IjoxNzQzMTI3OTc5fQ.h3xvmuNjeyFeshEZRVRLCsARgTpx4xeZQHQuZzESm2U';
const email = 'ahmed@sa1234dsad.com';
const password = '123123123';
let orgainzationId = 'hpgpqfqom8zic574';
let authenticationToken = '';
let AuthorizationHeader = '';
beforeAll(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
@@ -21,6 +25,16 @@ afterAll(async () => {
await app.close();
});
jest.retryTimes(3, { logErrorsBeforeRetry: true });
// jest.retryTimes(3, { logErrorsBeforeRetry: true });
export { app, orgainzationId, authenticationToken };
beforeAll(async () => {
const signinResponse = await request(app.getHttpServer())
.post('/auth/signin')
.send({ email, password })
.expect(201);
authenticationToken = signinResponse.body.access_token;
AuthorizationHeader = `Bearer ${authenticationToken}`;
})
export { app, orgainzationId, authenticationToken, AuthorizationHeader };