Skip to content
masterclass Buddy

Vitest · Matcher

toContain

toContain checks that an array or iterable contains a specific item. It can also check that a string contains a substring.

Last updated

Syntax

expect(received).toContain(expected)

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

Subscribe
  • toContainEqual
  • toContainElement
  • toHaveLength
  • expect

Source: expect | Vitest. Checked 2026-11-03.