Skip to content

This site describes solve-engine as it is on main: 2.43.0, which npm does not have yet. npm installs 2.40.0, so a page may show an answer that version does not give yet.

expectDocument

function expectDocument(
engine,
text,
options?
): Promise<DocumentAssertion>;

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

Evaluate text as a whole document on engine, wait for any live values it starts to settle, and return per-line matchers.

The document goes through the incremental pass a live editor uses (evaluateDocument), so every whole-document form resolves: line references, category tags, table columns and goal seek. While any line is Pending, the kit awaits ExpressionEngine.settle and evaluates the document again, until none is or the deadline passes. A line still Pending at the deadline is left Pending, for ExpressionAssertion.toBePending to confirm or another matcher to report.

ParameterType
engineExpressionEngine
textstring
optionsSettleOptions

Promise<DocumentAssertion>

const doc = await expectDocument(engine, ":rate = 4%\n1000 * rate");
doc.line(2).toEqual(40);