Lately, I've been in the process of upgrading my Angular version from 10 to 13 in order to utilize TypeScript 4.6. However, during this upgrade, I made some errors with types in my tests and I'm wondering if others have encountered similar issues. The specific error message I'm encountering is:
Argument of type '(state: ExampleStateModel) => Example' is not assignable to parameter of type 'StateToken<unknown> | AsymmetricMatcher<any>'.ts(2345)
To make all my tests compile and run, I resorted to using @ts-ignore
, but I'm hoping for a better solution. Here's an example of code that fails:
store = TestBed.inject(Store);
spyOn(store, 'selectSnapshot')
.withArgs(ExampleState.clinic).and.returnValue({ id: 1 })
And here's an example of code that works:
store = TestBed.inject(Store);
// @ts-ignore
spyOn(store, 'selectSnapshot').withArgs(ExampleState.clinic).and.returnValue({ id: 1 })
For reference, here's the Example State code snippet:
@Injectable()
export class ExampleState {
@Selector()
public static clinic(state: ExampleStateModel) {
return state.clinic;
}
}
I also attempted running
npm i -D jasmine@latest jasmine-core@latest @types/jasmine@latest
My main question is related to how to properly use withArgs()
with an ngxs store. Any guidance or assistance would be greatly appreciated.