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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ExpressionAssertion(expression, outcome): ExpressionAssertion;Defined in: packages/engine/src/testing/index.ts:226
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
expression | string |
outcome | Outcome |
Returns
Section titled “Returns”ExpressionAssertion
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”Methods
Section titled “Methods”toBeError()
Section titled “toBeError()”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.
Returns
Section titled “Returns”this
toBePending()
Section titled “toBePending()”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.
Returns
Section titled “Returns”this
toEqual()
Section titled “toEqual()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
expected | string | number | boolean |
unit? | string |
Returns
Section titled “Returns”this
toEvaluate()
Section titled “toEvaluate()”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.
Returns
Section titled “Returns”this
toFailWith()
Section titled “toFailWith()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
code | string |
Returns
Section titled “Returns”this