In before each I have created a store spy obj
store = jasmine.createSpyObj<SomeState>('Store', ['pipe', 'dispatch'])
In individual test I want to return a mock for a specific selector. Using withargs doesnt seems to work.
store.pipe.withArgs(select(someSelector1)).and.returnValue(of(someMock))
store.pipe.withArgs(select(someSelector2)).and.returnValue(of(someMock2))
The only way to mock selectors is to use returnvalues and return mock observable in the order they are bring called in source code, like so:
store.pipe.and.returnValues(of(someMock1), of(someMock2))
Another alternative is to use select instead of pipe in source code and spy on store select instead of pipe, like so:
store = jasmine.createSpyObj<SomeState>('Store', ['pipe', 'dispatch', 'select'])
store.select.withArgs(someSelector1).and.returnValue(of(someMock))
store.select.withArgs(someSelector2).and.returnValue(of(someMock2))
but this doesnt work when the selector takes a parameter like this:
store.select.withArgs(someSelector(param)).and.returnValue(of(mock))