Skip to content
codefastlabs

Command Palette

Search for a command to run...

v0.1.1· Changelog

@codefast/di-testing

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.