-
Notifications
You must be signed in to change notification settings - Fork 718
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
Property injection with multiple tests in seperate files #266
Comments
Hi thanks for reporting. I will investigate and try to fix this ASAP. |
Hi, I'm trying to reproduce this issue in our unit test. I'm using the following test: it("Trying to reproduce issue #266", () => {
const kernel = new Kernel();
let pInject = makePropertyInjectDecorator(kernel);
let symbols = {
IC: Symbol("IC")
};
class A {
public b: B;
constructor() {
this.b = new B("test");
}
};
class B {
public name: string;
@pInject(symbols.IC)
public c: IC;
constructor(name: string) {
this.name = name;
}
};
interface IC {
test: string;
getName(name: string): string;
}
@injectable()
class C implements IC {
public test: string;
constructor() {
this.test = "this is a test property";
}
public getName(name: string): string {
return "this is the getName function " + name;
}
}
kernel.bind<IC>(symbols.IC).to(C);
let a = new A();
expect(a.b).not.eql(undefined);
expect(a.b.name).eql("test");
expect(a.b.c.getName(a.b.name)).eql("this is the getName function " + a.b.name);
}); The test is working so I'm almost sure that your problem is the same as #262. You are importing As I explained in #262:
import "reflect-metadata";
So you need to change your code to import "reflect-metadata" only once in your whole application. |
Sorry, it is indeed the problem with importing the metadata. I hadn't noticed the #262 issue. |
No problem 😄 happy to help. |
using: inversify@2.0.0-beta.10
I'm getting an error using property injection for one of the two tests.
When i remove one of these tests no errors at all.
Error: Missing required @Injectable annotation in: C.
I recreated the problem in a small project see url below.
I can't figure out what the problem might be.
My guess would be something gets executed twice.
repo:
https://github.com/carbosound1/inversify-testing-example
you can use "gulp watch" or "gulp test" to run karma
The text was updated successfully, but these errors were encountered: