Skip to content

docs: explain dependency injection with Sinon - #2756

Draft
Frostand wants to merge 1 commit into
sinonjs:mainfrom
Frostand:andrew/dependency-injection-guide
Draft

docs: explain dependency injection with Sinon#2756
Frostand wants to merge 1 commit into
sinonjs:mainfrom
Frostand:andrew/dependency-injection-guide

Conversation

@Frostand

@Frostand Frostand commented Aug 2, 2026

Copy link
Copy Markdown

Purpose (TL;DR) - mandatory

Fixes #1458 by adding an executable guide that demonstrates plain dependency injection with a Sinon stub, without module interception.

Background (Problem in detail) - optional

The existing how-to material covers link seams, while #1458 asks for a small no-framework dependency-injection example. The guide shows a factory that accepts its API dependency, a production composition root, and a test that injects and asserts a Sinon stub.

Solution - optional

  • add the dependency-injection guide and link it from the how-to overview/sidebar
  • add an executable documentation test for the returned value and exact call arguments
  • update the sidebar generator and generated sidebar together

How to verify - mandatory

  1. Check out this branch.
  2. Run npm install at the repository root and in docs/.
  3. Run the following checks:
    • root npm run build-artifacts
    • root npm run test-node — 1,556 passing; 12 pending
    • root npm run lint
    • root npm run prettier:check
    • docs npm run test:docs — 733 passing
    • docs npm run docs:build

Known baseline limitations: docs-wide lint/format checks report existing issues in untouched tests and generated files, and link checking requires the external lychee binary. The new guide/test and edited generator pass targeted lint/format checks; no dependency or lockfile changed.

Checklist for author

  • npm run lint passes
  • No uncached standard-library references are introduced by this documentation example.

Tooling disclosure: this change was prepared with OpenAI Codex and validated with the commands above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document how to do simple dependency injection

1 participant