0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.