Skip to content

Instantly share code, notes, and snippets.

@Klerith
Last active February 20, 2025 14:21
Show Gist options
  • Save Klerith/c6cc2681ad8f540082ebcfe325e202aa to your computer and use it in GitHub Desktop.
Save Klerith/c6cc2681ad8f540082ebcfe325e202aa to your computer and use it in GitHub Desktop.
Tarea sobre pruebas
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