-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correção dos testes #95
Conversation
const nameInput = screen.getByLabelText('Nome completo'); | ||
userEvent.type(nameInput, 'Kleber da silva'); | ||
|
||
const cityInput = screen.getByLabelText('Cidade'); | ||
userEvent.selectOptions(cityInput, 'campinas'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Além dos wrappers, estavam faltando estes dois campos que eram obrigatórios também
projectId: jest.fn(12345), | ||
}), | ||
auth: jest.fn().mockReturnThis(), | ||
signInWithCustomToken: jest.fn().mockResolvedValue(), | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creio que estes e outros mocks podem ser melhorados no futuro criando "customRenders", para cada um desses providers como neste exemplo
jest.mock('firebase/app', () => { | ||
return { | ||
firestore: jest.fn(() => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Há uma outra lib que resolve isso, mas não é 100% segura então resolvi adicionar somente o necessário para o teste funcionar
expect(newCandidates.length).toEqual(20); | ||
act(() => { | ||
userEvent.click(loadMorebutton); | ||
jest.runOnlyPendingTimers(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Utilizei para rodar os timers do setTimeout
interno do componente
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Massa, muito obrigado pela contribuição, @luistak!
O que
Correção dos testes:
Adição do jsdom como env do jest corrigindo este problema
Verificações