Skip to content

feature: Disable eager service loading for testsΒ #380

Open
@South-Paw

Description

@South-Paw

Description

I started using the eager flag on some of my @Services that I would expect to be started as soon as they are registered (Database, Logger, Mailer, etc) which works great πŸ‘

However when unit testing, these services are registering themselves during tests that don't require them and then beginning their start up routines (initializing connections etc) which causes tests to fail or have other issues

Proposed solution

Would it be possible to set some configuration on the Container to instruct it to ignore eager services when testing?

Other alternatives I've tried/thought about

  • Mocking the eager services in a setupTests file (however this didn't seem to work, they are still registered then starting up)
  • I suppose I could remove the this.start() calls from the service's constructors, but then I'll have to get them from the container to manually call start() on them (which sort of defeats the purpose of the eager πŸ˜„)

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    flag: needs discussionIssues which needs discussion before implementation.type: featureIssues related to new features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions