-
-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] DITest cannot handle multi-instance injection #2709
Labels
Comments
Hello @supercoffee this is because const providers = DITest.injector.getMany(Symbol("token_type"))
// or use the real token provider FakeCrmClient
const provider = DITest.invoke(FakeCrmClient, []) See you |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When using DiTest / PlatformTest, classes registered using a "type" instead of "provide" key in order to allow multi-instance injection. This functionality seems to work when running the actual server instance, but when writing tests using injection, these instances don't seem to be resolved.
Inside a test, I'm unable to create an instance of the ApiClient using DiTest.invoke or PlatformTest.invoke. Either one fails the same way, either some cryptic
TypeError ReflectMetadata
error or the result being undefined.Scenario
I have several instances of an API client that I want to inject into a service. I've decorated them all with a decorator like so
To Reproduce
Run the following code snippet (using Jest framework).
The last two test fail in a similar manner. Something to the effect of
I have also seen the following error but I can't figure out exactly what circumstances produce this vs the previous error
Expected behavior
DiTest.invoke
/PlatformTest.invoke
should produce an instance or instances of a provider registered using thetype
property.Code snippets
No response
Repository URL example
No response
OS
macOS
Node version
Node 18.13.1
Library version
7.69.4
Additional context
No response
The text was updated successfully, but these errors were encountered: