首次使用 Jest。通过以下代码来初始化组件测试:
describe('CreateComponent', () => {
let component: CreateQuoteComponent;
let fixture: ComponentFixture<CreateQuoteComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CreateQuoteComponent ]
});
fixture = TestBed.createComponent(CreateQuoteComponent);
component = fixture.componentInstance;
}));
test('should exist', () => {
expect(component).toBeDefined();
});
});
运行时,某些组件中的导入存在问题
Test suite failed to run Cannot find module' with '
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:259:17)
at Object.<anonymous> (src/app/modules/xxx/components/landing/create/create.component.ts:19:1)
这方面有何线索,或是否已知有解决方法?