Skip to main content

Minecraft-Specific Matchers

toHaveReceivedMessage(message, options?)

Waits for the bot to receive a message containing (or exactly matching) the text or RegExp.
Parameters:
  • message (string | RegExp) - Text or pattern to search for
  • options.strict (boolean) - Require exact match (default: false)
  • options.since (number) - Buffer index to search from
  • options.timeout (number) - Max wait time in ms

toContainItem(itemName)

Waits for the player’s inventory to contain an item with the specified name.
Parameters:
  • itemName (string) - Minecraft item name (e.g., ‘diamond’, ‘stone_sword’)
Timeout: 5 seconds

toHaveLore(text, options?)

Asserts that a GUI item locator contains specific lore text, with automatic retry.
Parameters:
  • text (string) - Text that should appear in lore
  • options.timeout (number) - Max wait time in ms (default: 5000)
  • options.pollingRate (number) - Check interval in ms (default: 100)

Basic Equality

toBe(value)

Strict equality check using Object.is(). Use for primitives.

toEqual(value)

Deep equality check. Use for objects and arrays.

Truthiness

toBeTruthy() / toBeFalsy()

toBeNull() / toBeUndefined() / toBeDefined()

toBeNaN()

Numbers

toBeGreaterThan(number) / toBeGreaterThanOrEqual(number)

toBeLessThan(number) / toBeLessThanOrEqual(number)

toBeCloseTo(number, precision?)

Floating-point comparison with precision (default: 2 decimal places).

Strings

toMatch(regexOrString)

toContain(substring)

Works on both strings and arrays.

Arrays and Collections

toContainEqual(item)

Deep equality check for array items.

toHaveLength(number)

Objects

toHaveProperty(keyPath, value?)

toMatchObject(object)

Subset matching for objects.

Exceptions

toThrow(expected?)

toThrowAsync(expected?)

Async version for async functions.

Types

toBeInstanceOf(class)

Negation

All matchers support .not:

Tips

  1. Use appropriate matchers: toBe() for primitives, toEqual() for objects/arrays
  2. Async matchers must be awaited: toHaveReceivedMessage, toContainItem, toHaveLore, toThrowAsync
  3. Use the most specific matcher for your use case — it produces clearer failure messages
  4. All matchers support .not for negation
  5. Minecraft matchers have a 5-second default timeout

Error Messages

When assertions fail, you get clear messages: