Skip to content
masterclass Buddy

Jest · Matcher

toHaveLength

toHaveLength checks that a value has a length property with a specific numeric value. It is useful for testing array and string sizes.

Last updated

Syntax

expect(value).toHaveLength(number)

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

Subscribe
  • expect(value)
  • not

Source: Expect · Jest. Checked 2026-11-03.