PackageAssertion
Defined in: packages/engine/src/testing/index.ts:477
Assertions about a package’s declared descriptor, returned by
expectPackage. These catch the three mistakes the issue calls out,
before the package is ever registered. Every matcher returns this and
throws an ExpectationError when it fails.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new PackageAssertion(pkg): PackageAssertion;Defined in: packages/engine/src/testing/index.ts:478
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
pkg | IEnginePackage |
Returns
Section titled “Returns”PackageAssertion
Methods
Section titled “Methods”notToCollideWith()
Section titled “notToCollideWith()”notToCollideWith(others, strictness?): CompatibilityReport;Defined in: packages/engine/src/testing/index.ts:520
Assert the package does not collide with any of others in a way that
would silently break one of them (two packages claiming the same lexer
keyword, plugin-function index, async-resolver namespace, and so on).
strictness sets which severities fail the assertion: "error" (the
default) fails only on the collisions that always break something,
"warning" also fails on the ones that silently pick a winner, "info"
fails on cosmetic overlaps too.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
others | IEnginePackage[] | undefined |
strictness | CollisionStrictness | "error" |
Returns
Section titled “Returns”the full compatibility report, so a test can inspect every conflict, including ones below the strictness threshold.
notToShadow()
Section titled “notToShadow()”notToShadow(words?): ShadowedWord[];Defined in: packages/engine/src/testing/index.ts:492
Assert none of the package’s claimed words shadow a prose word.
A trigger word that is also an ordinary word turns a line of prose into
arithmetic, the single most common package mistake and the subject of the
trigger-words guide. This checks the words the package declares
(lexer keywords, units, operators, and single-word phrases) against
words (defaulting to COMMON_PROSE_WORDS), case-insensitively.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
words | readonly string[] | COMMON_PROSE_WORDS |
Returns
Section titled “Returns”the shadowed words, empty when the package is clean, for a test that wants to inspect rather than assert.
toDeclareCompatibleEngineVersion()
Section titled “toDeclareCompatibleEngineVersion()”toDeclareCompatibleEngineVersion(engineVersion?): this;Defined in: packages/engine/src/testing/index.ts:551
Assert the package’s declared engineVersion range is satisfied by the
running engine (or by engineVersion when given).
A package that declares a range and never checks it resolves is the third mistake the issue names: it looks fine until the one engine version it cannot run against, where the range either fails to match or turns out to be a malformed string. A package with no declared range passes (no constraint is always compatible).
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
engineVersion | string | ENGINE_VERSION |
Returns
Section titled “Returns”this