Last active
February 20, 2025 14:21
-
-
Save Klerith/c6cc2681ad8f540082ebcfe325e202aa to your computer and use it in GitHub Desktop.
Tarea sobre pruebas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Test, TestingModule } from '@nestjs/testing'; | |
import { INestApplication, ValidationPipe } from '@nestjs/common'; | |
import * as request from 'supertest'; | |
import { getRepositoryToken } from '@nestjs/typeorm'; | |
import { Repository } from 'typeorm'; | |
import { AppModule } from '../../../src/app.module'; | |
import { User } from '../../../src/auth/entities/user.entity'; | |
const testingUser = { | |
email: '[email protected]', | |
password: 'Abc12345', | |
fullName: 'Testing user', | |
}; | |
describe('AuthModule Register (e2e)', () => { | |
let app: INestApplication; | |
let userRepository: Repository<User>; | |
beforeEach(async () => { | |
const moduleFixture: TestingModule = await Test.createTestingModule({ | |
imports: [AppModule], | |
}).compile(); | |
app = moduleFixture.createNestApplication(); | |
app.useGlobalPipes( | |
new ValidationPipe({ | |
whitelist: true, | |
forbidNonWhitelisted: true, | |
}), | |
); | |
await app.init(); | |
// TODO: obtener el userRepository del módulo - (getRepositoryToken?) | |
// userRepository = app.get | |
}); | |
afterEach(async () => { | |
await app.close(); | |
}); | |
it('/auth/register (POST) - no body', async () => { | |
// Evaluar errores esperados | |
}); | |
it('/auth/register (POST) - same email', async () => { | |
// TODO: Asegurarse de guardar un usuario con el correo | |
}); | |
it('/auth/register (POST) - unsafe password', async () => { | |
// Evaluar errores esperados | |
}); | |
it('/auth/register (POST) - valid credentials', async () => { | |
// TODO: Borrar el usuario antes de crearlo de nuevo | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment