Changelog
for @ghostry/extern-extension-fabricator-v0
Every release of @ghostry/extern-extension-fabricator-v0, newest first. Its guide is Extern, in fabricator's docs.
v0.0.7
Fixes
- Types resolve for consumers on
moduleResolution: node16ornodenext. The published declarations imported their sibling files without an extension, which those modes reject for an ESM package. UnderskipLibCheck: truethere was no error: every export was silently typed asany. Every relative import indist/typesnow names its file.
Compatibility
- Peer dependencies raised to
@ghostry/extern >=0.0.17 <0.1.0and@ghostry/fabricator >=0.0.15 <0.1.0, the first versions whose own types resolve undernode16andnodenext. Since@ghostry/extern0.0.16,initialize()returns the instance directly, and the README example no longerawaits it.
Internal
- The build type-checks the emitted declarations, so a broken
dist/typesfails the build instead of shipping.
v0.0.6
Breaking changes
- A built Fabricator is no longer a block identity. Pass the schema it was built from. Given a Fabricator, a block could either keep drawing from it or build a new one from its schema in the testing block's scope, and nothing at the call site would say which.
extern.typed.by(built).will(() => fetchUser()); // before extern.typed.by(built.schema).will(() => fetchUser()); // now Builtis no longer exported.
Compatibility
- Peer dependency on
@ghostry/fabricatorraised to>=0.0.13 <0.1.0.isSchema, which rejects a built Fabricator (and accepts a schema), is exported from@ghostry/fabricator/internalin that version.
v0.0.5
Internal
- The package's repository, homepage, and issue links point at github.com/ghostry-dev/extern.
- Source is formatted with
bun fmt. Dependencies were updated.
v0.0.4
Fixes
extern.typed.by(schema)keepsundefinedin a fabricator schema's value type.T.undefinable(row)inferred asRow, and a block that returnedundefinedwas rejected.[Produces]is optional, and withoutexactOptionalPropertyTypesan optional property reads asX | undefined, which swallowed the schema's ownundefined. The identity now matches fabricator'sProduced<$T>box, so the inferred type is the same with that flag on or off.
Compatibility
- Peer dependency on
@ghostry/fabricatorraised to>=0.0.11 <0.1.0.Producedis exported from@ghostry/fabricator/internalin that version.
v0.0.3
Compatibility
- Peer dependency on
@ghostry/externraised to>=0.0.14 <0.1.0. The extension opens its fabricator scope from aframe()generator, which replacesscope()in that version.
Behavior change
- A synchronous
extern.testingbody runs, including on the synchronous carrier a browser bundle selects. An async body still needsnode:async_hooks. Fabricator'swraprefuses an async block on that carrier. - With
@ghostry/extern/harnessing, the order of the two integrations is the order the salt layers nest. Either order keeps every layer, from@ghostry/fabricator0.0.6 on, and gives each test its own data. Flipping the order moves every fabricated value. The extension's instance has to be the integrated instance or an ancestor of it. A per-testwrapnever governs a fork of the integrated instance, and handing the extension that fork fabricates the same values in every test, with no error.rootcatches twoinitialize()calls. It does not catch the fork, which shares a root.
v0.0.2
Behavior change
- A fabricated value no longer depends on the file that opened
extern.testingor the file that wroteby(). Every testing block layers one constant,"@ghostry/extern", onto the instance's salt and starts its construction counter over. The same schema draws the same value from any file. A tail-call-elided wrapper can no longer move a value. - An unnamed block's value still follows construction order inside that testing block. A named block's does not: the name is applied with
ordinal: null, so the value is a function of the identity and the name, and fabricating something else ahead of it does not move it. A salt on its own would still take the next ordinal. Fabricator treats a salt as a pin, not a fork. new Fabricator(schema)inside the block shares the block's source and is a separate draw. One written outside the block draws from the enclosing scope. The constant layer keeps the nth fabrication inside the block from equaling the nth outside it.- The scope wraps
context.scope(), the frame in effect, rather than the instance passed tofabricatorExtension. Awrapon that instance would restate from it and drop an enclosing frame, including the per-test salt from@ghostry/fabricator/harnessing. The extension and that integration have to be instances from oneinitialize(). Afork()stays in the lineage. A secondinitialize()does not, even given the samestack, and nothing is thrown: every test fabricates the same values, so a test that writes an id into shared state passes alone and fails as a suite.
Compatibility
- Peer dependency on
@ghostry/fabricatorraised to>=0.0.4 <0.1.0, whereseedis renamed tosalt:initializeFabricator({ seed: "my-suite" }); // before initializeFabricator({ salt: "my-suite" }); // now
v0.0.1
Initial release.
A typed extern block built from a @ghostry/fabricator schema fabricates a value when it has no mock, instead of throwing NotMockedError. An extern instance without the extension still rejects fabricator schemas.
import { initialize as initializeExtern } from "@ghostry/extern";
import { initialize as initializeFabricator } from "@ghostry/fabricator";
import { fabricatorExtension } from "@ghostry/extern-extension-fabricator-v0";
const fabricator = initializeFabricator({ seed: "my-suite" });
export const extern = await initializeExtern({
extensions: [fabricatorExtension({ instance: fabricator })],
});
mock(schema).with(value) replaces the value outright. mock(schema).produce(({ via }) => via.fabricate({ name: "Ada" })) shapes it through fabricator's own fabricate. via is the built Fabricator, so an object's overrides are fabricator's, including nested objects and Omitted. unmocked: "error" makes an unmocked block throw NotMockedError again. produce() still fabricates on demand.
Two files feed each value. The testing block's file, with :line:col stripped, layers the salt, so the layer is per file. The file that wrote by() is the attribution. The same block therefore fabricates the same value across testing() calls, and moving either file changes the value. A name passed to named distinguishes two blocks over one schema. Attribution reads the stack, so a one-line wrapper around by() can be tail-call-elided and the attribution falls through to that wrapper's caller.
Needs a runtime with node:async_hooks — Bun, Node, or Deno. The extension runs the testing block inside fabricator's wrap, which refuses an async block on the synchronous carrier a browser bundle selects.
npm install @ghostry/extern-extension-fabricator-v0 @ghostry/extern @ghostry/fabricator
Compatibility
- Peers are
@ghostry/extern >=0.0.13 <0.1.0and@ghostry/fabricator >=0.0.2 <0.1.0.
