0% found this document useful (0 votes)
2 views

TAU_Jest JavaScript Testing Framework

The document outlines a course on the Jest JavaScript Testing Framework, detailing its structure, content, and key concepts such as installation, common matchers, asynchronous testing, and snapshot testing. It includes links to resources, a GitHub repository, and various tools required for the course. The document is prepared by Rajat Verma and provides insights into automated testing using Jest.

Uploaded by

abhimanyu thakur
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

TAU_Jest JavaScript Testing Framework

The document outlines a course on the Jest JavaScript Testing Framework, detailing its structure, content, and key concepts such as installation, common matchers, asynchronous testing, and snapshot testing. It includes links to resources, a GitHub repository, and various tools required for the course. The document is prepared by Rajat Verma and provides insights into automated testing using Jest.

Uploaded by

abhimanyu thakur
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

====================================================

Tutor: Toyer Mamoojee


Reference: Test Automation University
Course: Jest JavaScript Testing Framework
====================================================
1. Document prepared by
a. Rajat Verma
i. Github Profile: https://github.com/rajatt95

ii. Github Page: https://rajatt95.github.io

iii. LinkedIn: https://www.linkedin.com/in/rajatt95

iv. Topmate: https://topmate.io/rajatt95

v. Telegram: https://t.me/rajatt95

vi. Instagram: https://www.instagram.com/rajattvermaa95

vii. Youtube: https://www.youtube.com/@rajatt95


—------------------
2. Test Automation Frameworks available on Github
a. WEB

i. Selenium WebDriver + Java

ii. Cypress + (Javascript and Typescript)

iii. Playwright + (Javascript and Typescript)


b. MOBILE

i. Appium + Java
c. API

i. Rest Assured + Java

ii. Requests + Python

-------------------------------------------------------------------------------------------------------------------------------

1
—------------------
1. Documents:

a. Github repository: https://github.com/rajatt95/Documents

b. Google Drive:
https://drive.google.com/drive/folders/1tne9pZjgWvfrS0l9tVHs6k1jnQHpTLoA

2. Last worked on this Document:


a. Apr 18, 2023

3. Learnings from Tutor (Code Repository):


a. This course:
i. https://github.com/stars/rajatt95/lists/tau-tm-jest
b. Other course(s):
i. https://github.com/stars/rajatt95/lists/tau-toyer-mamoojee

—------------------
4. Course content:
a. Jest JavaScript Testing Framework
b. Chapter 1 - Introduction to Jest
c. Chapter 2 - Installing Jest
d. Chapter 3 - Writing Your First Test
e. Chapter 4 - Common Matchers
f. Chapter 5 - Jest Matchers Expanded
g. Chapter 6 - Before and After Code
h. Chapter 7 - Running Specific Tests
i. Chapter 8 - Asynchronous Testing in Jest
j. Chapter 9 - Snapshot Testing

—------------------
Softwares:
1. Programming language - Javascript
2. IDE - VS Code
a. https://code.visualstudio.com/download
b. Plugin
i. Playwright Test for VSCode
3. Engine:
a. https://nodejs.org/en/download/

—------------------

-------------------------------------------------------------------------------------------------------------------------------

2
—------------------
1. Learnings from Course (TAU - Toyer Mamoojee - JEST)
a. Links:
i. Jest
1. https://jestjs.io/docs/expect
—------------------
b. Jest
i. What is Jest?
ii. Why use Jest?
iii. When to use Jest?
—------------------
c. Common Matchers in Jest
i. toBe()
ii. toEqual()
iii. Matchers (https://jestjs.io/docs/expect)
1. String matchers
2. Number matchers
3. Truthiness matchers
4. Array matchers
—------------------
d. Before and After Types
i. beforeEach()
ii. afterEach()
iii. beforeAll()
iv. afterAll()
—------------------
e. Run tests
i. Run all tests in a project folder
ii. Run specific test file
iii. Run a single test in a file
iv. Run tests in watch mode
—------------------
f. Ways to handle asynchronous code
i. Callbacks
ii. Promises
iii. async/await
—------------------
g. Snapshot Testing

—------------------

-------------------------------------------------------------------------------------------------------------------------------

3
—------------------
h. Commands
i. To verify the setup for node JS
1. node --version
ii. Create package.json file
1. npm init -y
iii. Install Jest
1. npm install --save-dev jest
iv. If the Editor is not giving intellisense
1. npm i @types/jest --save-dev

v. Run tests
1. Run all tests in a project folder
a. npm run test
2. Run specific test file
a. npm run test multiply.test.js
3. Run a single test in a file

====================================================

-----------------------------------------
========Jest JavaScript Testing Framework ==========
-----------------------------------------

1. In this course, we’ll learn how to create automated tests using Jest
2. What is Jest
a. Open-source testing framework
b. It was initially developed by Facebook
c. It has the capabilities
i. Assertion library
ii. Execute tests parallelly
1. Faster test execution

—------------------

-------------------------------------------------------------------------------------------------------------------------------

4
-----------------------------------------
========Chapter 1 - Introduction to Jest ==========
-----------------------------------------

1. What is Jest?
a. It is an open-source javascript testing library from Facebook
b. It is not just a Test runner, but, it is a complete testing framework
i. That has brought modern testing to another level

2. Why use Jest?


a. Ease of setup
b. Super fast execution
i. Parallelization
c. Does Snapshots
i. It allows capturing the image that represents your ended component or
response and store in a file
ii. Then, you can compare it later to ensure that the UI or response didn’t
change
d. All Built-in one
i. Matchers
ii. Spies
iii. Runner
iv. Mocking library

3. When to use Jest?


a. Unit testing
b. API testing
i. With other JS libraries like
1. SuperTest
2. Request-Promise
c. UI testing
i. With other JS libraries like
1. Puppeteer
d. DB testing
i. Against
1. MongoDB
2. DynamoDB

—------------------

-------------------------------------------------------------------------------------------------------------------------------

5
-----------------------------------------
========Chapter 2 - Installing Jest ==========
-----------------------------------------

1. Pre-Requisites
a. IDE - VS Code
i. https://code.visualstudio.com/download
ii. Plugin
1. Playwright Test for VSCode
b. Engine:
i. https://nodejs.org/en/download/

2. Commands
a. To verify the setup for node JS
i. node --version

b. Create package.json file


i. npm init -y

c. Install Jest
i. npm install --save-dev jest

d. If the Editor is not giving intellisense


i. npm i @types/jest --save-dev

—------------------

1.

-------------------------------------------------------------------------------------------------------------------------------

6
-----------------------------------------
========Chapter 3 - Writing Your First Test ==========
-----------------------------------------

1.

2.

—------------------
1. To execute the test
a. npm run test

2.
—------------------

-------------------------------------------------------------------------------------------------------------------------------

7
-----------------------------------------
========Chapter 4 - Common Matchers ==========
-----------------------------------------

1. Common Matchers in Jest


a. Matchers are methods that let you test your values
b. Most common matchers
i. toBe() -
1. Strict equality
2. For value checking
ii. toEqual() - test the value of an object

2.

3.

—------------------

-------------------------------------------------------------------------------------------------------------------------------

8
-----------------------------------------
========Chapter 5 - Jest Matchers Expanded ==========
-----------------------------------------

1. Matchers (https://jestjs.io/docs/expect)
a. String matchers
b. Number matchers
c. Truthiness matchers
d. Array matchers

—------------------

1.

2.
-------------------------------------------------------------------------------------------------------------------------------

9
—------------------

3.

—------------------

1.

-------------------------------------------------------------------------------------------------------------------------------

10
—------------------

2.

-----------------------------------------
========Chapter 6 - Before and After Code ==========
-----------------------------------------

1. Before and After code


a. Also, can be referred to as
i. Setup - executes before test case
ii. Teardown - executes after test case
b. Types
i. beforeEach()
ii. afterEach()
iii. beforeAll()
iv. afterAll()

—------------------

-------------------------------------------------------------------------------------------------------------------------------

11
—------------------

1.

2.

—------------------

-------------------------------------------------------------------------------------------------------------------------------

12
-----------------------------------------
========Chapter 7 - Running Specific Tests ==========
-----------------------------------------

1. Run tests

a. Run all tests in a project folder


i. npm run test

b. Run specific test file


i. npm run test multiply.test.js

c. Run a single test in a file


i. test.only

ii.

—------------------

-------------------------------------------------------------------------------------------------------------------------------

13
—------------------
d. Run tests in watch mode

i.
1. npm run test:watch

2.

—------------------

-------------------------------------------------------------------------------------------------------------------------------

14
-----------------------------------------
========Chapter 8 - Asynchronous Testing in Jest ==========
-----------------------------------------

1. Ways to handle asynchronous code


a. Callbacks
b. Promises
c. async/await

—------------------

1.

2.

—------------------

-------------------------------------------------------------------------------------------------------------------------------

15
-----------------------------------------
========Chapter 9 - Snapshot Testing ==========
-----------------------------------------

1. Snapshot Testing
a. According to the official documentation of Jest
i. It states that snapshots are a great new way of testing UI components
b. Very useful when you want to make sure that your application UI does not change
unexpectedly
c. The test fails
i. If snapshots are not matched
1. Snapshot #1 - Reference
2. Snapshot #2 - Takes at runtime
d. It is possible to test and assert the output of any serializable value

—------------------

1.

—------------------

-------------------------------------------------------------------------------------------------------------------------------

16
—------------------

2.
—------------------
1. Once we execute the tests

a.
i. A new folder (__snapshots__) gets created
1. It created a snapshot of our expected values

-------------------------------------------------------------------------------------------------------------------------------

17
=======================================================================

1. Documents

a. Github repository: https://github.com/rajatt95/Documents

b. Google Drive:
https://drive.google.com/drive/folders/1tne9pZjgWvfrS0l9tVHs6k1jnQHpTLoA

2. Learnings from Tutor (Code Repository)


a. This course:
i. https://github.com/stars/rajatt95/lists/tau-tm-jest
b. Other course(s):
i. https://github.com/stars/rajatt95/lists/tau-toyer-mamoojee

3. To connect

a.
=======================================================================

=======================================================================

-------------------------------------------------------------------------------------------------------------------------------

18

You might also like