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

Зміст курсу

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?

Виберіть правильну відповідь

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?

Виберіть кілька правильних відповідей

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 5
some-alt