Conteúdo do Curso
Introduction to QA Automation Testing
Introduction to QA Automation Testing
Writing Unit Tests Task
Some minor updates have been made to the application. The application now stores encrypted passwords for better data-protection. Moreover, the username and password are validated in login and registration forms to ensure:
- Username is at least 3 letters long;
- Password is at least 6 letters long;
There is an empty Test Script in the __tests__
folder, called validation.js
.
Your task is to write test cases in Jest, which aim to test the two validation functions validateUsername
and validatePassword
. Also run the Test Coverage Report to see how much of the code in utils
folder is covered by the tests.
Following are the four test cases you have to convert into code:
Test Case 1
- Title: Validate that a simple alphanumeric username is accepted;
- Precondition: The validateUsername function is available;
- Test Steps: Pass the string 'testuser' to the validateUsername function;
- Expected Result: The function should return true;
Test Case 2
- Title: Validate that a username with spaces is accepted;
- Precondition: The validateUsername function is available;
- Test Steps: Pass the string 'firstname lastname' to the validateUsername function;
- Expected Result: The function should return true;
Test Case 3
- Title: Validate that a mixed case password is accepted;
- Precondition: The validatePassword function is available;
- Test Steps: Pass the string 'examplePassword' to the validatePassword function;
- Expected Result: The function should return true;
Test Case 4
- Title: Validate that an alphanumeric password is accepted;
- Precondition: The validatePassword function is available;
- Test Steps: Pass the string 'qwerty123' to the validatePassword function;
- Expected Result: The function should return true;
Obrigado pelo seu feedback!