Documentación oficial sobre Jest
- Instalaciones de desarrollo (super test es útil para probar Express)
npm install -D jest @types/jest ts-jest supertest
Documentación oficial sobre Jest
npm install -D jest @types/jest ts-jest supertest
(() => { | |
// Aplicando el principio de responsabilidad única | |
// Priorizar la composición frente a la herencia! | |
type Gender = 'M'|'F'; | |
interface PersonProps { | |
birthdate : Date; | |
gender : Gender; |
// Primera forma: Siempre que el catch devuelva un New Error... | |
describe('createException', () => { | |
test('should create exception successfully', async () => { | |
const errorMock: object = null; | |
const customerAccListMock: object = null; | |
const responsServiceMock: object = null; | |
const prueba: Promise<void> = service.createException(errorMock, customerAccListMock, responsServiceMock); | |
await expect(async() => await prueba ).rejects.toBeInstanceOf(BusinessException); | |
await expect(async() => await prueba ).rejects.toMatchObject({ |
Table users { | |
user_id integer [pk, increment] | |
username varchar [not null, unique] | |
email varchar [not null, unique] | |
password varchar [not null] | |
name varchar [not null] | |
role varchar [not null] | |
gender varchar(10) [not null] | |
avatar varchar |