最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Vitest for Angular - Stack Overflow

programmeradmin4浏览0评论

I am trying to use Vitest to write a unit test for an Angular project. I want to use testbed (@angular/core/testing) to configure the test module like below:

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      imports: [TestComponent],
      providers: [
        ChangeDetectorRef,
        ElementRef,
        FormBuilder,
        { provide: Router, useValue: {} },
      ],
    })pileComponents(); // Ensure external resources are resolved

    // Create the component instance
    const fixture = TestBed.createComponent(TestComponent);
    component = fixtureponent instance;
  });

I am trying to use testbed to use the lifecycle hooks of Angular component. But with the code above, it throw the exception:

Error: Component 'ChipComponent' is not resolved:
templateUrl: ./chipponent.html
Did you run and wait for 'resolveComponentResources()'?

How can I fix this issue and use Vitest for Angular?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论