Reputation: 2762
I'm using Inversify for Dependency Injection in my TypeScript Node.js application. This works great when actually running the app.
However, the @injectable()
annotation seems to have crippled my tests. When running tests, I now get an error saying:
TypeError: Reflect.hasOwnMetadata is not a function
I've seen this before, and was helped by this other SO answer: https://stackoverflow.com/a/43115660/4003671
However, importing inversify.config
does not solve the problem in my tests. If I remove the @injectable()
annotation from the class I'm testing, then the tests run.
I don't actually need DI in my tests, so somehow disabling it would be an acceptable solution.
Has anyone seen this before?
Upvotes: 0
Views: 2035
Reputation: 2762
Think I've got it. Importing my entire inversify.config
didn't work, but if I specifically import "reflect-metadata"
at the top of my unit test, it's all dandy.
Upvotes: 1