I'm trying to follow official Akita
docs on unit testing with Angular
: https://datorama.github.io/akita/docs/angular/tests/.
However I'm having problems with mocking TodosQuery
return value. This is the specific line:
todosQuery.selectAll.and.returnValue(of([createTodo(), createTodo()]))
And this is the error thrown:
Property 'and' does not exist on type '{ (options: SelectAllOptionsA<Todo>): Observable<HashMap<Todo>>; (options: SelectAllOptionsB<Todo>): Observable<...>; (options: SelectAllOptionsC<...>): Observable<...>; (options: SelectAllOptionsD<...>): Observable<...>; (options: SelectAllOptionsE<...>): Observable<...>; (): Observable<...>; }'.
Maybe the docs are outdated and this is no longer supported? Is this still the preferred way to mock Query
returning value?
These are my package.json dependencies:
"dependencies": {
"@angular/animations": "~12.2.0",
"@angular/common": "~12.2.0",
"@angular/compiler": "~12.2.0",
"@angular/core": "~12.2.0",
"@angular/forms": "~12.2.0",
"@angular/platform-browser": "~12.2.0",
"@angular/platform-browser-dynamic": "~12.2.0",
"@angular/router": "~12.2.0",
"@datorama/akita": "^6.2.3",
"@datorama/akita-ng-entity-service": "^6.2.0",
"@datorama/akita-ng-router-store": "^6.0.0",
"rxjs": "~6.6.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~12.2.5",
"@angular/cli": "~12.2.5",
"@angular/compiler-cli": "~12.2.0",
"@datorama/akita-ngdevtools": "^6.0.0",
"@types/jasmine": "~3.8.0",
"@types/node": "^12.11.1",
"jasmine-core": "~3.8.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.3.5"
}
I believe there is a missing step in the tests beforeEach
spyOn(todosQuery, 'selectAll');