Skip to content

docs: add plugin dependency testing guidance#6737

Open
jhcpeixoto wants to merge 1 commit into
fastify:mainfrom
jhcpeixoto:docs/plugin-di-testing
Open

docs: add plugin dependency testing guidance#6737
jhcpeixoto wants to merge 1 commit into
fastify:mainfrom
jhcpeixoto:docs/plugin-di-testing

Conversation

@jhcpeixoto
Copy link
Copy Markdown

Closes #5190\n\nThis adds a focused Testing guide section for using Fastify plugins and decorators as dependency injection points. It shows how to register a fake dependency in the parent context before registering the route plugin under test, and links back to getDecorator and fastify-plugin for dependency validation and encapsulation behavior.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 27, 2026
Comment thread docs/Guides/Testing.md
Comment on lines +485 to +488
Fastify plugins can also provide dependencies to the parts of an application
that need them. A common pattern is to register a plugin that decorates the
Fastify instance with a repository, API client, or service, then register the
routes that use that decorator below the dependency plugin.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incredibly verbose and doesn't read well at all.

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

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Guide: Dependency Injection via the Fastify Plugin System

2 participants