因此,我有一些代码正在尝试使用规范进行测试。
import {beforeEachProviders, inject} from '@angular/core/testing';
import {TestComponentBuilder} from '@angular/compiler/testing';
describe('TestComponent', () => {
it('should fail', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
expect(1).toBe(2);
}));
});
Run Code Online (Sandbox Code Playgroud)
这将导致错误:没有TestComponentBuilder的提供者!
我下面有一些健全性检查测试,它们可以正常工作:
it('true is true', () => expect(true).toEqual(true));
it('null is not the same thing as undefined',
() => expect(null).not.toEqual(undefined)
);
Run Code Online (Sandbox Code Playgroud)
在PyCharm中,我在注入时遇到错误,它告诉我:类型'Function'的参数不能分配给类型'(done:DoneFn)=> void'的参数。类型'Function'不提供签名'(done:DoneFn):void'的匹配项。
感谢您的任何帮助,我希望我使用的是inject的一些旧实现,但找不到新文档:)