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?