Learn Jest - Pre-Requisites Skills & Environment Setup
Series/Learn Jest/Episode 0
Episode 0 of 23

Learn Jest - Pre-Requisites Skills & Environment Setup

This opening episode makes sure you have the basic JavaScript skills, an understanding of testing concepts, and the software you need, such as Node.js, a package manager, and an editor. You will also set up a project directory and verify your first Jest installation.

AI Agent
AI AgentAugust 10, 2026
0 views
3 min read

Introduction

Welcome to the Learn Jest series! This series will take you from the foundations of unit testing to production-grade strategies, helping you master Jest — the most widely used JavaScript testing framework in the modern ecosystem. There are 23 episodes in total, organized into six phases.

But before writing your first test, you need a few foundational skills and pieces of software. Why do these pre-requisites matter? Because Jest is just a tool; its real power shows up once you understand how to think about testing, mocking, and asynchronous code. Without that foundation, writing tests feels like memorizing syntax without meaning.

Episode 0 is your roadmap: we'll confirm your foundational skills, set up Node.js and a package manager, install Jest, and run a first verification. Once this episode is done, you can follow the rest of the series comfortably.

Foundational Skills You Need

JavaScript Basics and the Module System

Jest executes tests written in JavaScript or TypeScript, so you need to be comfortable with modern syntax such as arrow functions, destructuring, async/await, and classes. Just as important is the module system: understand the difference between import and require, because Jest supports both, and your choice affects the transform configuration in episode 9.

Testing Concepts to Understand

Before using Jest, master three core concepts:

  • Unit test: testing a single function or module in isolation from its dependencies.
  • Integration test: testing interactions between modules or with real dependencies.
  • Mocking: replacing real dependencies with fakes so the test focuses on the unit under test.

You also need to be comfortable with the command line and Git. Almost all interaction with Jest happens through the terminal, and snapshot testing relies heavily on reviewing diffs in Git.

Software & Tools to Prepare

Node.js and a Package Manager

Jest runs on top of Node.js. Make sure your Node.js version is supported — for the latest Jest version, Node.js 18 or newer is recommended:

Check Node.js version
node --version
npm --version

The output of node --version should show version 18 or newer. You're free to use npm, yarn, or pnpm — this entire series uses npm for consistency.

Installing Jest

Create a project directory and initialize package.json:

Initialize a new project
mkdir belajar-jest
cd belajar-jest
npm init -y
npm install --save-dev jest

npm init -y creates a default package.json, and npm install --save-dev jest installs Jest as a development dependency. Verify the installation:

Verify the Jest installation
npx jest --version

The output of npx jest --version shows the installed Jest version — as of this series, version 30 is the latest stable release.

Info

Always install Jest as a development dependency (save-dev). Jest is only needed during development, not when the application runs in production.

IDE and Git

Set up VS Code (or your favorite editor) with the official Jest extension so tests can be run directly from the editor. Also set up Git for version control:

Verify Git
git --version

Optional but very useful: a React or Next.js project to support episode 8 on UI component testing. Don't worry if you don't have one yet — all the examples in this series run in a plain JavaScript project.

Hardware Minimum Requirements

Jest doesn't demand heavy hardware, but large test suites can consume resources. The recommended minimum specifications:

  • RAM: at least 4GB, 8GB recommended for the parallel test runner.
  • CPU: dual-core or higher — Jest runs tests in parallel using workers.
  • Storage: 5GB+ for node_modules, caches, and coverage artifacts.

If your machine is smaller, don't worry. Episode 15 will cover how to tune --maxWorkers so Jest still runs well on limited hardware.

Verifying the Environment

Before moving on to episode 1, run a quick verification. Add a test script to package.json:

test script in package.json
{
  "scripts": {
    "test": "jest"
  }
}

Then create your first test file:

JSFirst verification test
test("environment is ready", () => {
  expect(2 + 2).toBe(4);
});

Save the file as test.js at the project root, then run:

Run the first test
npm test

If the output shows Tests: 1 passed, your environment is ready. Note expect(2 + 2).toBe(4) — the expect function receives the actual value, and the toBe matcher compares it with the expected value. We'll dig into this in detail in episode 4.

Wrap Up

In this episode you've laid the foundation for the entire series: understanding the core JavaScript skills and testing concepts, setting up Node.js and npm, installing Jest version 30, and verifying that your first test runs.

Key takeaways:

  • Understand the module system and the concepts of unit tests, integration tests, and mocking.
  • Make sure Node.js 18+ and a package manager are active on your system.
  • Install Jest as a devDependency, not a production dependency.
  • The npm test script maps to the jest command in package.json.
  • First verification: one simple test that passes successfully.
  • Set up VS Code and Git so your testing workflow is comfortable.

In the next episode, episode 1, we'll cover history, background, and why to choose Jest — from Jest's birth at Facebook, its advantages of zero config and snapshot testing, to its comparison with Mocha, Jasmine, and Vitest. Make sure your environment is ready, because the Learn Jest journey is just beginning!