Skip to content
masterclass Buddy

Jest · Matcher

toBeDefined

Jest's toBeDefined matcher checks that a value is not undefined. Use it when a function or expression should produce a defined result.

Last updated

Syntax

expect(value).toBeDefined()

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

Subscribe
  • expect(value)
  • toBeUndefined
  • toBeNull
  • toBeTruthy
  • toBeFalsy

Source: Using Matchers · Jest. Checked 2026-11-03.