I have a unique scenario where I have implemented a service that accesses ngrx selectors and a component that utilizes this service by injecting it and adjusting properties based on the values retrieved.
For unit testing purposes, I am creating mock versions of the service to return various values for different tests. To achieve this, I have modified the mock service to use subjects instead of observables. Although the tests are successful, TypeScript raises an error indicating that the interface of the mock service does not align with the actual service since the latter uses observables.
The Stackblitz demonstration functions correctly, but TS shows the error: TS2339: Property 'next' does not exist on type 'Observable'
I discovered that I could address this issue by adding // @ts-ignore above each .next() call to instruct TypeScript to overlook the error. However, I believe there might be a more efficient solution available.
Is there a better method to mock the service so it retains observables while offering the flexibility to provide distinct values for individual unit tests?