Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Get Started with Jest | Jest
Expert React

bookGet Started with Jest

Jest is a testing framework widely used in React projects. It provides a bunch of useful utilities. Jest is easy to configure, supports code coverage, and is a powerful tool for testing React components and applications.

Setting up a new React project with Jest

Step 1: Create a new React project

Let's create a new React project using create-react-app in the terminal:

npx create-react-app .

Step 2: Install Jest library

Since Jest is not pre-installed with create-react-app, we must install it separately to enable testing for the React project. To install Jest, open the terminal and run the following command:

npm install jest

This will download and install Jest. Additionally, it will update the package.json file to include Jest in the dependencies section. The package.json should now include Jest similar to the following:

"dependencies": {
  "@testing-library/jest-dom": "^5.16.5",
  "@testing-library/react": "^13.4.0",
  "@testing-library/user-event": "^13.5.0",
  "jest": "^27.5.1",
  "react": "^18.2.0",
  "react-dom": "^18.2.0",
  "react-scripts": "5.0.1",
  "web-vitals": "^2.1.4"
},

Project overview

The Jest learning will consist of theoretical and practical parts. In the following chapters, we will learn how to write tests for the Counter App. This approach will help us understand the theory better and apply our knowledge immediately through practical examples.

Note

The app has been entirely built but still lacks tests. Please take the time to inspect the app and ensure that everything is clear. As in the following chapters, we will dive into testing.

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

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

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

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

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Suggested prompts:

Запитайте мені питання про цей предмет

Сумаризуйте цей розділ

Покажіть реальні приклади

Awesome!

Completion rate improved to 1.96

bookGet Started with Jest

Свайпніть щоб показати меню

Jest is a testing framework widely used in React projects. It provides a bunch of useful utilities. Jest is easy to configure, supports code coverage, and is a powerful tool for testing React components and applications.

Setting up a new React project with Jest

Step 1: Create a new React project

Let's create a new React project using create-react-app in the terminal:

npx create-react-app .

Step 2: Install Jest library

Since Jest is not pre-installed with create-react-app, we must install it separately to enable testing for the React project. To install Jest, open the terminal and run the following command:

npm install jest

This will download and install Jest. Additionally, it will update the package.json file to include Jest in the dependencies section. The package.json should now include Jest similar to the following:

"dependencies": {
  "@testing-library/jest-dom": "^5.16.5",
  "@testing-library/react": "^13.4.0",
  "@testing-library/user-event": "^13.5.0",
  "jest": "^27.5.1",
  "react": "^18.2.0",
  "react-dom": "^18.2.0",
  "react-scripts": "5.0.1",
  "web-vitals": "^2.1.4"
},

Project overview

The Jest learning will consist of theoretical and practical parts. In the following chapters, we will learn how to write tests for the Counter App. This approach will help us understand the theory better and apply our knowledge immediately through practical examples.

Note

The app has been entirely built but still lacks tests. Please take the time to inspect the app and ensure that everything is clear. As in the following chapters, we will dive into testing.

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

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

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

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