Skip to main content

@rbxts/expect > ExpectMessageBuilder > trailingFailurePrefix

ExpectMessageBuilder.trailingFailurePrefix() method

Adds a string to the end of the existing prefix, but only if it's a failure.

Signature:

trailingFailurePrefix(str?: string): this;

Parameters

Parameter

Type

Description

str

string

(Optional) The string to add to the end of the prefix.

Returns:

this

This instance, for chaining.

Remarks

Usually, this means !negated. So you can also look at this as a trailing prefix for non negated use-cases.

Comes before the suffix.

Note that there can only be one, calling this method again will replace the previous value- not append to it

Example

new ExpectMessageBuilder(
`Expected ${place.name} to ${place.not} equal ${place.expected.value}`
).trailingFailurePrefix(", but it was not");

// Would be the same as
new ExpectMessageBuilder(
`Expected ${place.name} to equal ${place.expected.value}, but it was not`,
`Expected ${place.name} to NOT equal ${place.expected.value}`
);