help-me-mom / ng-mocks

Angular testing library for mocking components, directives, pipes, services and facilitating TestBed setup
https://www.npmjs.com/package/ng-mocks
MIT License
1.05k stars 76 forks source link

attach MockProvider to useClass and useValue if it is possible #599

Closed satanTime closed 2 years ago

satanTime commented 3 years ago

An investigation is needed to check whether there is a way how to attach MockInstance to all possible provider configurations.

return MockBuilder(XComponent, XModule)
      .provide([
        { provide: Store, useClass: StoreMock },
      ]);
satanTime commented 2 years ago

Due to ctor deps, there is no an easy way to create instances based on classes. The only way is to use ngMocks.defaultMock, which has access to injector and provides required flexibility.

satanTime commented 2 years ago

v13.5.0 has been released and contains a fix for the issue. Feel free to reopen the issue or to submit a new one if you meet any problems.