Skip to main content

@rbxts/expect > extendNegations

extendNegations() function​

Add additional negations to expect().

Signature:

declare function extendNegations(methods: ReadonlyArray<string>): void;

Parameters​

Parameter

Type

Description

methods

ReadonlyArray<string>

An array of property names to use as negations

Returns:

void

Remarks​

A negation is a property that flips an assertion.

For example:

expect(5).to.not.equal(4);

In this case, not is the negation.

Instead of checking if 5 === 5, we are now checking if 5 !== 5.

Note that negations flip one another, so this passes:

expect(5).to.never.not.equal(4);

Example​

// augment the expect module so typescript knows the properties exists
declare module "@rbxts/expect" {
interface Assertion<T> {
readonly not: this;
readonly never: this;
}
}

// add the properties to expect for runtime usage
extendNegations(["not", "never"]);