Jest

Jest testing framework commands for unit and integration testing

19 commands
Search & Copy
Save Favorites
19
Total Commands
100%
Free Access
Lightning Fast

Available Commands

Click on any command to copy it instantly

19 commands available
19 of 19
jest

Install Jest

Install Jest testing framework

npm install --save-dev jest
jest
install
testing
jest

Initialize Jest

Initialize Jest configuration

npx jest --init
jest
init
config
jest

Run Tests

Run Jest tests

npm test
jest
run
test
jest

Watch Mode

Run tests in watch mode

npm test -- --watch
jest
watch
development
jest

Coverage Report

Generate test coverage report

npm test -- --coverage
jest
coverage
report
jest

Mock Functions

Create mock functions for testing

const mockFn = jest.fn()
jest
mock
functions
jest

Test Suites

Group related tests together

describe("Component", () => { ... })
jest
describe
suites
jest

Individual Tests

Write individual test cases

it("should do something", () => { ... })
jest
it
test
jest

Assertions

Make assertions in tests

expect(value).toBe(expected)
jest
expect
assertions
jest

Setup and Teardown

Setup and teardown functions

beforeEach(() => { ... })
jest
before
setup
jest

Async Testing

Test asynchronous code

it("should resolve", async () => { ... })
jest
async
promises
jest

Snapshot Testing

Test component snapshots

expect(component).toMatchSnapshot()
jest
snapshot
components
jest

Timer Mocks

Mock timers in tests

jest.useFakeTimers()
jest
timer
mock
jest

Module Mocking

Mock entire modules

jest.mock("./module")
jest
module
mock
jest

Jest Configuration

Configure Jest settings

module.exports = { testEnvironment: "node" }
jest
config
settings
jest

React Testing

Test React components

npm install --save-dev @testing-library/react
jest
react
components
jest

DOM Testing

Test DOM elements

expect(element).toBeInTheDocument()
jest
dom
elements
jest

Custom Matchers

Create custom matchers

expect.extend({ toBeWithinRange })
jest
custom
matchers
jest

Debug Tests

Debug failing tests

npm test -- --verbose
jest
debug
troubleshoot

Missing a command?

Help us improve this collection by suggesting commands that should be added. Your contributions help the entire developer community!