robot-test-methods
v1.0.2
Published
A package for interacting with elements using @testing-library/react
Downloads
14
Maintainers
Readme
Robot Test Methods
Este pacote contém um conjunto de funções utilitárias para interagir com elementos da interface do usuário em testes usando Robot Pattern. Ele usa a biblioteca @testing-library/react
para simular eventos do usuário.
Instalação
Para instalar este pacote, você precisa ter o Node.js e o npm instalados em sua máquina. Depois, você pode instalar o pacote com o seguinte comando:
npm install robot-test-methods
Importação
Depois de instalar o pacote, você pode importá-lo em seu arquivo de teste da seguinte maneira:
import setup from 'robot-test-methods';
e desestruturar os metodos do setup
dessa forma:
const { interactWithElement, fillInput, clickButton } = setup;
Agora você pode usar as funções interactWithElement
, fillInput
e clickButton
em seus testes conforme necessário.
Funções
O pacote contém as seguintes funções:
interactWithElement(elementText, event)
⇒
Esta função procura um elemento na tela pelo texto e dispara um evento. Se nenhum evento for especificado, um clique será disparado.
fillInput(placeholderText, value)
⇒
Esta função procura um campo de entrada (input) pelo texto do placeholder e preenche com o valor fornecido.
clickButton(buttonText)
⇒
Esta função procura um botão pelo texto e dispara um evento de clique.
Contribuindo
Contribuições são bem-vindas. Por favor, abra uma issue primeiro para discutir o que você gostaria de mudar.