Skip to content
masterclass Buddy

Jest · Function

test

Jest lets you write JavaScript and TypeScript tests with assertions and matchers. Install it as a development dependency, add a test script, and run the tests with npm test or yarn test.

Last updated

Syntax

test(name, callback)
expect(value).toBe(expected)
 beforeEach(callback)
 afterEach(callback)
 beforeAll(callback)
 afterAll(callback)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • expect
  • toBe
  • test.only
  • describe
  • beforeEach
  • afterEach
  • beforeAll
  • afterAll

Source: Getting Started · Jest. Checked 2026-11-03.