Skip to content

ExpressionAssertion

Defined in: packages/engine/src/testing/index.ts:225

Assertions about the result of one evaluated expression, returned by expectExpression. Every matcher returns this, so assertions chain, and throws an ExpectationError when it fails.

new ExpressionAssertion(expression, outcome): ExpressionAssertion;

Defined in: packages/engine/src/testing/index.ts:226

ParameterType
expressionstring
outcomeOutcome

ExpressionAssertion

get value(): Value;

Defined in: packages/engine/src/testing/index.ts:232

The raw resolved Value, for an assertion the matchers do not cover. Throws if the expression failed.

Value

toBeError(): this;

Defined in: packages/engine/src/testing/index.ts:312

Assert the expression failed (a thrown engine error or a plugin-raised error value). Says nothing about the code.

this


toBePending(): this;

Defined in: packages/engine/src/testing/index.ts:355

Assert the expression returned a value still resolving asynchronously. The kit evaluates synchronously, so a package whose result comes from an async resolver reports pending on first evaluation, this is how a test confirms the async path was taken without resolving it.

this


toEqual(expected, unit?): this;

Defined in: packages/engine/src/testing/index.ts:268

Assert the expression evaluated to expected, and, when unit is given, that the result carries exactly that unit. A number compares against the value’s numeric magnitude within a small floating-point tolerance; a string compares against the value’s own string; a boolean against its boolean reading. Omitting unit leaves the unit unchecked, so toEqual(5) passes for both 5 and 5 gp.

ParameterType
expectedstring | number | boolean
unit?string

this


toEvaluate(): this;

Defined in: packages/engine/src/testing/index.ts:248

Assert the expression evaluated to a value (not an error, not a pending async result). Says nothing about what the value is.

this


toFailWith(code): this;

Defined in: packages/engine/src/testing/index.ts:329

Assert the expression failed with exactly code, the error catalog code (e.g. "UNDEFINED_VARIABLE", or a package’s own code). Reports the code it actually got when they differ, so a near-miss is obvious.

ParameterType
codestring

this