Skip to main content

expect package

Test-agnostic assertion library for ROBLOX.

Remarks

Exports the expect() method as the primary entry point.

Classes

Class

Description

ExpectMessageBuilder

Builder for creating messages in an expect() method.

Functions

Function

Description

computeFullProxyPath(proxy)

Recursively resolves the path and parent of a Proxy to create a full path from the root.

createProxy(value, parent, path)

Creates a Proxy around a value.

err(callback, messages)

Helper function for testing expect error messages.

Throws an error if the callback doesn't throw.

expect(value, customMessage)

Perform assertions/checks on the state of a value.

extendMethods(methods)

Adds additional methods to expect().

extendNegations(methods)

Add additional negations to expect().

extendNOPs(methods)

Add additional NOOPs to expect().

getDefaultExpectConfig()

Gets the (current) default ExpectConfig.

getNearestDefinedProxy(proxy)

Finds the nearest proxy in the hierarchy that has a non null value, if any.

getProxyParent(proxy)

Safely gets the parent of a proxy, without triggering any metamethods.

getProxyPath(proxy)

Safely gets the path of a proxy, without triggering any metamethods.

getProxyValue(proxy)

Safely gets the value of a proxy, without triggering any metamethods.

isProxy(value)

Type guard for Proxy values.

resetDefaultExpectConfig()

Resets the default ExpectConfig.

setDefaultExpectConfig(config)

Sets the default ExpectConfig.

withProxy(value, callback)

Creates a Proxy around a value, and calls the callback with it.

Interfaces

Interface

Description

ActualPlaceholder

The "actual" variable in an expect() statement.

Assertion

Parent interface for all expect() calls.

ExpectConfig

Configuration setting for expect().

Configuration is generally used inline as needed, as the concept of expect instances doesn't really exist.

ExpectedPlaceholder

The "expected" variable in an expect() statement.

ExpectMessageBuilderOptions

Configuration options for instances of ExpectMessageBuilder.

Placeholder

Utility interface for specifying dynamic variables in expect error messages.

ProxyInstance

The data attached to a Proxy.

VariableData

Data about the variables in an expect statement.

Variables

Variable

Description

place

Utility constant for specifying dynamic variables in expect error messages.

Type Aliases

Type Alias

Description

CustomMethodImpl

The implementation of a expect() method.

CustomMethodImpls

An object of expect() method names to implementations.

EnumValue

The value of an enum in a LuaEnum.

ExpectMethodResult

The result of an expect() method call.

Filter

Callback for deciding if a value satisfies a condition.

InferArrayElement

Helper type for inferring the type of an array.

LuaEnum

A user-defined enum, as it would be defined in the transpiled Lua.

Proxy

A wrapper around a value T that provides meta context on index access.

TypeCheckCallback

Callback for deciding if a value matches a given type T.