JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 27
  • Score
    100M100P100Q52653F
  • License MIT

Additional Jest matchers for roblox-ts projects.

Package Exports

  • @rbxts/jest-extended
  • @rbxts/jest-extended/package.json

Readme

@rbxts/jest-extended

Additional Jest matchers for roblox-ts. Port of jest-extended.

Installation

pnpm add @rbxts/jest-extended

Setup

import * as matchers from "@rbxts/jest-extended";

expect.extend(matchers);

Or add individual matchers:

import { toBeFalse, toBeTrue } from "@rbxts/jest-extended";

expect.extend({ toBeFalse, toBeTrue });

Type declarations are included automatically via types.d.ts.

Matchers

Boolean

  • .toBeTrue()
  • .toBeFalse()
  • .toBeBoolean()

Number

  • .toBeNumber()
  • .toBeInteger()
  • .toBeEven()
  • .toBeOdd()
  • .toBePositive()
  • .toBeNegative()
  • .toBeFinite()
  • .toBeWithin(start, end)
  • .toBeBetween(startDate, endDate)
  • .toBeInRange(min, max)

String

  • .toBeString()
  • .toBeSymbol()
  • .toBeHexadecimal()
  • .toStartWith(prefix)
  • .toEndWith(suffix)
  • .toInclude(substring)
  • .toIncludeMultiple(substrings)
  • .toIncludeRepeated(substring, times)
  • .toEqualCaseInsensitive(value)
  • .toEqualIgnoringWhitespace(value)

Array

  • .toBeArray()
  • .toBeArrayOfSize(size)
  • .toBeEmpty()
  • .toIncludeAllMembers(members)
  • .toIncludeAnyMembers(members)
  • .toIncludeSameMembers(members)
  • .toIncludeAllPartialMembers(members)
  • .toIncludeSamePartialMembers(members)
  • .toPartiallyContain(member)
  • .toSatisfy(predicate)
  • .toSatisfyAll(predicate)
  • .toSatisfyAny(predicate)

Object

  • .toBeObject()
  • .toBeEmptyObject()
  • .toBeFrozen()
  • .toContainKey(key)
  • .toContainKeys(keys)
  • .toContainAllKeys(keys)
  • .toContainAnyKeys(keys)
  • .toContainValue(value)
  • .toContainValues(values)
  • .toContainAllValues(values)
  • .toContainAnyValues(values)
  • .toContainEntry(entry)
  • .toContainEntries(entries)
  • .toContainAllEntries(entries)
  • .toContainAnyEntries(entries)

Function

  • .toBeFunction()
  • .toThrowWithMessage(type, message)

Mock

  • .toHaveBeenCalledOnce()
  • .toHaveBeenCalledExactlyOnceWith(...args)
  • .toHaveBeenCalledBefore(mock)
  • .toHaveBeenCalledAfter(mock)

Date (DateTime)

  • .toBeDate()
  • .toBeValidDate()
  • .toBeAfter(date)
  • .toBeBefore(date)
  • .toBeAfterOrEqualTo(date)
  • .toBeBeforeOrEqualTo(date)

Mutator

  • .toChange(checker)
  • .toChangeBy(checker, by)
  • .toChangeTo(checker, to)

Other

  • .toBeOneOf(members)
  • .pass(message?)
  • .fail(message?)

Not yet ported

Matcher Status
toResolve Async matchers not yet supported
toReject Async matchers not yet supported

Unsupported matchers

These upstream matchers have no Luau equivalent and are not included:

Matcher Reason
toBeBigInt No BigInt in Luau
toBeSealed No Object.isSealed
toBeExtensible No Object.isExtensible
toBeNil Already in base jest
toBeNaN Already in base jest
toBeDateString No string-to-date parsing

LICENSE

MIT