Skip to content
codefastlabs

Command Palette

Search for a command to run...

v0.4.0· Changelog

@codefast/di-testing

0.4.0

Minor Changes

  • #1101 Breaking: a test bed's dispose() is renamed disposeAsync(), matching @codefast/di's Container#disposeAsync() — it returns a Promise, so it carries the Async suffix. await using bed = …compile() is unchanged; replace await bed.dispose() with await bed.disposeAsync().

  • #1068 Lower the Node.js floor from 24 to the lowest release the package, its dependencies and its full test suite run on: 22.12 for @codefast/cli and @codefast/tailwind-variants, 22.18 for @codefast/di and @codefast/di-testing, and 22.22.2 for @codefast/theme, @codefast/tracking and @codefast/ui. Each floor is type-checked against what Node 22 ships and proven by running the package's tests on that release in CI.

Patch Changes

  • #1120 The README and the test bed's internals follow @codefast/di's rename of optional() to injectOptional().
  • Updated dependencies:

0.3.0

Minor Changes

  • #999 Requires @codefast/di 0.12, whose chains declare a binding's slot before its strategy; the test beds bind their mocks and real collaborators in that order.

Patch Changes

  • #1005 Breaking for deep subpath imports only — the root entry @codefast/di is unchanged. src/ now follows three rules, and the published subpaths follow src/ with no exception: a directory names a family of two or more modules and a lone module sits flat at its layer; a directory carries the topic and a file its role, so no file repeats its directory's name; and the exports map is the source tree, so the strip that kept the introspection modules at flat specifiers is gone.

    Moves: the MetadataReader verification leaves resolution/cache/class-introspector for metadata/verify — it was the one value import pointing up from metadata/ into resolution/; the RESOLUTION_DIAGNOSTICS channel leaves errors/ for introspection/diagnostics; the fluent chain's contract leaves core/binding for core/binding-builders, and the class implementing it is container/binding-chain; effectiveBindingScope folds into core/binding.

    Renamed specifiers: ./errors/errors → ./errors; ./errors/diagnostics → ./introspection/diagnostics; ./ambient/active-container → ./ambient-container; ./container/binding-builders → ./container/binding-chain; ./core/binding-scope → gone (effectiveBindingScope is in ./core/binding); ./injection/resolve-options → ./injection/dependency-slot; ./metadata/{metadata-keys,metadata-types,metadata-reader-token,symbol-metadata-reader,verifying-metadata-reader} → ./metadata/{keys,types,reader-token,symbol-reader,verifying-reader}; ./lifecycle/{lifecycle-manager,scope-manager} → ./lifecycle/{hooks,scopes}; ./decorators/{lifecycle-decorators,decorator-metadata} → ./decorators/{lifecycle,metadata-record}; ./resolution/path/resolution-path → ./resolution/path; ./resolution/plan/{instantiation-plan,plan-codegen} → ./resolution/plan/{compiler,codegen}; ./resolution/select/binding-select → ./resolution/select/candidates; ./resolution/cache/binding-lookup-cache → ./resolution/cache/lookup; ./{inspector,explanation,dependency-graph,graph-adapters/*} → ./introspection/{inspector,explanation,dependency-graph,graph-adapters/*}. New: ./core/binding-builders, ./metadata/verify.

    @codefast/di-testing follows the one specifier it imports, metadata/verifying-reader.

  • Updated dependencies:

0.2.0

Minor Changes

  • #952 A suite now states its mock backend once, and a test bed can no longer be typed against one backend and built from another. createTestBed({ mockFactory, metadataReader? }) returns the entry point every bed begins from, its Backend inferred from the factory; TestBed.solitary(target) and TestBed.sociable(target) take the target only. The TestBed export is createTestBed({ mockFactory: defaultMockFactory }), the built-in spy with no framework needed.

    Before, the backend was chosen per call — TestBed.solitary(Unit, { mockFactory: () => vi.fn() }) — and TestBed.solitary<Unit, SinonStub>(Unit) with no factory type-checked, typed every mock as SinonStub, and built the default spy. Migrate by creating the suite's entry point once:

    import { createTestBed } from "@codefast/di-testing";
    import { vi } from "vitest";
    
    export const TestBed = createTestBed({ mockFactory: () => vi.fn() });

    TestBedOptions<Backend> configures createTestBed and requires mockFactory; TestBedStatic<Backend> names the entry point's backend and has no default. createTestBed throws the new MissingMockFactoryError (MISSING_MOCK_FACTORY) for a caller past the types who passes no factory, instead of standing the built-in spy in for a backend nobody chose.

  • #976 engines.node is now >=24.0.0, up from >=22.12.0, and Node 22 is no longer supported. Node 24.0.0 is the first release with explicit resource management built in (using, await using, DisposableStack, AsyncDisposableStack, SuppressedError) and all of ES2025, so the packages use both as the platform ships them instead of shimming them for an older line, and the CI matrix runs the unit suite on 24.0.0 itself. Move to Node 24, or stay on the current minor while a deployment still runs Node 22.

Patch Changes

  • #976 The README states what a program needs for the declarations' disposal members: the explicit resource management types, which no numbered lib declares before ES2027. @types/node 24 or later loads them, and so does ESNext.Disposable in lib. Without either, TypeScript 7 fails inside container.d.ts with TS2550 under skipLibCheck: false, and at await using with TS2318. @codefast/di-testing drops a /// <reference lib="esnext.disposable" /> that TypeScript 7 stripped from its emitted declarations anyway, and takes the lib from its tsconfig.json instead.

  • #956 README.md no longer quotes the @codefast/di peer range, which had fallen behind package.json — the release tooling moves that range, so the manifest is the one place it is stated.

  • #965 README.md now states TypeScript 7 or later as the floor for the package's types — the one compiler every @codefast/* package is built and checked with. No code or declaration changed.

  • Updated dependencies:

0.1.4

Patch Changes

  • #892 4c97c5b Thanks @thevuong! - Lower the monorepo's Node floor from 24 to 22.12, so the packages install and run on the active Node 22 LTS line.

    engines.node becomes >=22.12.0 across every package — the floor the shared toolchain (oxlint, Vite, Vitest, TanStack Start) already requires. Development stays on the latest Node (.node-version) for speed, and a CI matrix exercises the floor and the active LTS directly, so the floor is a contract CI proves rather than one everyone has to run. @types/node is pinned to the floor's major (^22), with a workspace override holding the whole tree there so a dev tool's @types/node: "*" peer can no longer pull a newer major and mask an API the floor lacks. The floor stays mechanical, not advisory: @codefast/di keeps its own Map upsert helpers rather than the ES2025 Map.prototype.getOrInsert (which would raise the floor to 26) and its lib stays ES2024. @codefast/cli's mirror step now calls the node:path functions directly instead of aliasing them, which the floor's types correctly flag as unbound methods.

    The shared @codefast/typescript-config presets pin lib and target to ES2024 (was ESNext) so the compiler's ECMAScript surface matches the Node floor: an ES2025 builtin such as Map.prototype.getOrInsert now fails to type-check rather than compiling and crashing on Node 22.12. @codefast/di and @codefast/di-testing already pinned lib and are unchanged.

    Internal subpath imports move from a #/ prefix to a bare # (#core/token, not #/core/token), and the package.json#imports keys become #*/#tests/*/#examples/* to match. Node's native ESM resolver rejects a #/-prefixed specifier with ERR_INVALID_MODULE_SPECIFIER on the whole Node 22 line (and on Node 24 before 24.14), and each package ships those specifiers verbatim inside its published dist/*.js for a consumer's Node to resolve — so this rename is what actually lets the packages import on the new floor. Purely internal: a consumer's own import paths are unchanged.

  • Updated dependencies [4c97c5b]:

0.1.3

Patch Changes

  • #827 0984174 Thanks @thevuong! - package.json now carries homepage and bugs, so npm links the package README and the issue tracker the way the other @codefast/* packages already do.

  • #848 ffb61a0 Thanks @thevuong! - README samples declare tokens with a <namespace>:<Name> display name, matching the convention @codefast/di documents.

  • Updated dependencies [0984174, d0b794c]:

0.1.2

Patch Changes

  • #791 37a212b Thanks @thevuong! - Point the README's license badge and "License" section at the package's own LICENSE file instead of the monorepo root.

  • #796 ba04d27 Thanks @thevuong! - Rewrite the README around one structure — what the package is, installation and requirements, a complete quick start, the concepts in learning order, then the documents and the license — with every API claim checked against the current code and no figures that go stale.

  • #784 ad2f93a Thanks @thevuong! - Ship the MIT LICENSE file in the published package. files already listed it, but the file was missing from the package directory, so the tarball had none.

  • Updated dependencies [37a212b, ba04d27, ad2f93a]:

0.1.1

Patch Changes

  • #774 176e95a Thanks @thevuong! - Fold di's reserved slotName criterion into slot addressing, so { name: "x" } and { tag: slotName.of("x") } — one slot to the container — are one slot to TestBed too: a mock registered with either spelling now matches a dependency declared with the other, and mocks.get(token, options) accepts both.
  • Updated dependencies [96af502]:

0.1.0

Minor Changes

  • #771 33c19b7 Thanks @thevuong! - Add @codefast/di-testing: solitary and sociable auto-mocking test beds for @codefast/di. TestBed.solitary(Class) reads a class's declared dependencies through di's MetadataReader, builds a mock for each, and constructs the real unit through a container so @postConstruct, accessor injection, and @preDestroy run as in production. The default mock is a zero-dependency spy; pass mockFactory: () => vi.fn() to build the mocks from Vitest, Jest, or Sinon — the factory's return type flows through the bed, so each backend's own mock API type-checks on mocks.get(...) and inside .stub callbacks with no adapter packages. Overrides cover fixed sealed values (.using), partial stubs (.stub), absent optionals (.absent), injectAll element lists (.usingAll), and slot-targeted mocks (.mock(token, { name })); beds expose resetMocks() and await using disposal. TestBed.sociable(Class).expose(Collaborator) keeps chosen class-keyed collaborators real (recursively, lifecycle included) while token-keyed dependencies stay mocked as the declared boundary; bed.exposed(Class) retrieves the real instances.