Skip to content

createTestEngine

function createTestEngine(packages?, options?): ExpressionEngine;

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

Build an ExpressionEngine loaded with the packages under test.

The built-in packages load first (unless TestEngineOptions.includeBuiltins is false), then each package in packages is registered in order, exactly as a host would. Registration is honest: a package whose declared engineVersion the running engine does not satisfy, or whose lexer keyword collides with a built-in, throws here rather than being swallowed. That is deliberately different from passing packages straight to the ExpressionEngine constructor, which contains a bad package by logging and continuing, useful in production, wrong for a test that needs to know the package it is testing actually loaded.

Call ExpressionEngine.clear when a test is finished with the engine if the test creates many, see the engine’s own lifecycle note.

ParameterTypeDefault value
packagesIEnginePackage[][]
optionsTestEngineOptions{}

ExpressionEngine

const engine = createTestEngine([myPackage]);
const engineOnly = createTestEngine([myPackage], { includeBuiltins: false });