Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Writing Unit Tests Task | Using a Test Automation Framework
Introduction to QA Automation Testing
course content

Course Content

Introduction to QA Automation Testing

Introduction to QA Automation Testing

1. Introduction to Automation Testing
2. Using a Test Automation Framework
3. Browser Automation with Selenium
4. Intro to Intermediate Automation Testing

bookWriting 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;
1. Which of the following files is not covered by the test cases at all according to the Test Coverage Report?
2. Which of the following lines from the `validation.js` file are NOT covered by test cases, according to the test coverage report?
Which of the following files is not covered by the test cases at all according to the Test Coverage Report?

Which of the following files is not covered by the test cases at all according to the Test Coverage Report?

Select the correct answer

Which of the following lines from the `validation.js` file are NOT covered by test cases, according to the test coverage report?

Which of the following lines from the validation.js file are NOT covered by test cases, according to the test coverage report?

Select a few correct answers

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 5
We're sorry to hear that something went wrong. What happened?
some-alt