是否可以测试 Angular 通用组件?
举个例子,如果我有
@Component({
...
})
export class MyComponent<T> implements OnInit {
public constructor(
private context: T
);
}
Run Code Online (Sandbox Code Playgroud)
其中 T 可以是任意数量的类。
然后最终我想编写一个 Jasmine 测试,但我无法确定创建测试装置时的正确语法:
fixture = TestBed.createComponent(MyComponent<MyTestObject>);
Run Code Online (Sandbox Code Playgroud)
TSLint 正是在这里抱怨:
Value of type 'typeof MyComponent' is not callable. Did you mean to include new?
Run Code Online (Sandbox Code Playgroud)
它显然认为我需要一个构造函数(?),但不清楚如何或在哪里实现它。
我正在尝试的事情可能吗?我可以找到通用组件的示例。我找不到设置测试夹具/组件的示例