Angular Karma Jasmine Error: Illegal state: Could not load the summary for directive

后端 未结 7 556
温柔的废话
温柔的废话 2021-02-03 16:47

I\'m developing a github repository (with angular 7 and angular-cli), and I have some tests with Karma and Jasmine working in the master branch.

Now I\'m trying to add l

7条回答
  •  轮回少年
    2021-02-03 17:02

    If you want to test a component without compiling it then you can by declaring it as a provider:

    beforeEach(() => {
      TestBed.configureTestingModule({
        // provide the component-under-test and dependent service
        providers: [
          WelcomeComponent,
          { provide: UserService, useClass: MockUserService }
        ]
      });
      // inject both the component and the dependent service.
      comp = TestBed.get(WelcomeComponent);
      userService = TestBed.get(UserService);
    });
    

    See: https://angular.io/guide/testing#component-test-basics

提交回复
热议问题