2

I am currently trying to remove the deprecated selectors in my application. This github issue telling us to declare selector with props as a function.

Old way (deprecated):

export const getCurrentScope = createSelector(getContextState, (state: ContextState, arg: string) => {
   return state.object + arg;
}

New Way:

export const getCurrentScope = (arg: string) => createSelector(getContextState, (state: ContextState) => {
   return state.object + arg;
}

With the deprecated method I was able to mock the selector by overriding it with the overrideSelector function.

Now that getCurrentScope is no longer a selector I cannot use the overrideSelector function.

So I'm trying to mock the function as follow:

import * as contextSelector from '@core/store/selectors/context.selectors';
spyOn(contextSelector, 'getCurrentScope').and.returnValue( ??? );

As I'm working with Angular Strict Mode, I have to return a MemoizedSelector but I do not find any way to perform it.

Can someone help me on this ?

pred
  • 185
  • 1
  • 14
  • What is the exact error? Is it possible to create a stackblitz with that problem? It would be easier to investigate and try out different ideas to solve the issue. – Erbsenkoenig Sep 07 '21 at 09:43
  • I found a solution by calling the reals selectors and wait for their return to get the value but I found this very complicated. I have no time for a stackBlitz now, the error is simply that the returnValue does not match with MemoizedSelector – pred Sep 07 '21 at 15:26

0 Answers0