jest
Jest — JavaScript Testing Framework
Jest brings a batteries-included approach to JavaScript testing. Where other frameworks require you to assemble a test runner, assertion library, and mocking tool separately, Jest ships all three in a single package. You install it, write a test, and run it. That simplicity is why it dominates the JavaScript testing landscape.
This skill walks you through Jest from first principles — writing assertions, mocking dependencies, testing asynchronous code, generating coverage reports, and integrating everything into a CI pipeline.
Installing and Configuring Jest
Every Jest setup begins with installation and a configuration file. Jest works out of the box for plain JavaScript, but most real projects need a bit of configuration for TypeScript, JSX, or module resolution.
# Install Jest and its TypeScript support
npm install --save-dev jest ts-jest @types/jest
Once installed, create a configuration file at the root of your project. The jest.config.ts format gives you type checking on your configuration options.
// jest.config.ts — Root Jest configuration for a TypeScript project