🧪 it
it(mensagem: string, cb: () => void)
|it(cb: () => void)
O it
é um auxiliar para ajudá-lo em casos como:
- Usar o
beforeEach
eafterEach
para cadait
realizado
Uso Básico
Agrupando testes
import { describe, it, assert } from 'poku';
describe('Conjunto de cálculos', () => {
it('Somas', () => {
assert.equal(1 + 1, 2);
assert.equal(2 + 2, 4);
});
it('Divisão', () => {
assert.equal(1 / 1, 1);
assert.equal(2 / 2, 1);
});
});
Aguardando Promessas
import { describe, it } from 'poku';
await describe(async () => {
await it(async () => {
// faça o que quiser
});
await it(async () => {
// faça o que quiser
});
});
Executando em paralelo
import { describe, it } from 'poku';
describe(() => {
it(async () => {
// faça o que quiser
});
it(async () => {
// faça o que quiser
});
});
Aguardando múltiplas promessas
import { describe, it } from 'poku';
await describe(async () => {
// faça algo antes
await Promise.all([
it(async () => {
// faça o que quiser
}),
it(async () => {
// faça o que quiser
}),
]);
// faça algo depois
});
dica
Você pode pensar nisso como beforeAll
e afterAll
.