@rbxts/expect > ExpectMessageBuilder > name
ExpectMessageBuilder.name() method
Sets a name to use for the "actual" variable, when dealing with messages without paths.
Signature:
name(value?: unknown): this;
Parameters
Parameter | Type | Description |
---|---|---|
value | unknown | (Optional) A displayable value to use as a name, or undefined to reset it (which defaults to the actual value). |
Returns:
this
This instance, for chaining.
Remarks
The value does not need to be a string, as the method will call tostring
for you.
This can be useful in try-catch blocks, as the error attached to catch
is undefined
due to typescript.
Example
Given the message:
new ExpectMessageBuilder(
`Expected ${place.name} to ${place.not} have a length
of ${place.expected.value}`
).name("the object");
For messages with paths:
Expected parent.cars to have a length of '3'
For messages without paths:
Expected the object to have a length of '3'