Skip to main content
It is possible to test services that use TypeOrmQueryService. The process is similar to the one described for nestjs, but it has a few differences. Let’s assume we have the following TodoItem service. For the sake of completeness, let’s also add a dependency on another service (let’s pretend that the todos have subTasks; we are not using relationships here):
todo-item.service.ts
Now lets write some tests!
todo-item.service.spec.ts

Mocking Inherited Methods

You can also mock inherited methods. Let’s change the getWithSubTasks method from the TodoItemService to use the getById method from the parent TypeOrmQueryService
To mock the getById method we can create a new spy with a mock implementation
Lets update our tests to mock out the getById implementation