Skip to content

arrayContain

.arrayContain()

Asserts that an array contains specified elements. Sets evaluation.result with missing values if the assertion fails.

Examples

Basic Usage

expect([1, 2, 3]).to.contain(2);
expect([1, 2, 3, 4, 5]).to.contain([2, 4]);

With Negation

expect([1, 2, 3]).to.not.contain(5);

What Failures Look Like

When the assertion fails, you’ll see a clear error message:

// This would fail:
expect([1, 2, 3]).to.contain(5);

Modifiers

This assertion supports the following modifiers:

  • .not - Negates the assertion
  • .to - Language chain (no effect)
  • .be - Language chain (no effect)