UnitReference.get
method return type mismatch
#439
-
Hi! I'm facing a weird behavior using NestJs and it's related I reproduced the problem in a simple application, which you can check here. I have the following test file: import type { Mocked } from '@suites/doubles.jest';
import { TestBed } from '@suites/unit';
import { BasicQueryHandler } from './basic-query.handler';
import { AppService } from './app.service';
import { BasicQuery } from './queries/basic-query';
import { APP_SERVICE, IAppService } from './interfaces/app.service';
describe('BasicQueryHandler', () => {
let handler: BasicQueryHandler;
let appService: Mocked<AppService>;
beforeEach(async () => {
const { unit, unitRef } =
await TestBed.solitary(BasicQueryHandler).compile();
handler = unit;
appService = unitRef.get<IAppService>(APP_SERVICE);
});
it('should return "Hello World!"', async () => {
appService.getHello.mockReturnValue('Hello MB!');
const result = await handler.execute(new BasicQuery('World'));
expect(result).toBe('Hello MB!');
});
}); The first execution is sucessful and this is the doc generated from the library about After installing
I checked the type files of Searching for a alternative, I chose to follow the recommendations from NestJs Doc, but I'd prefer to use the most recent version of Any clue on what's going on? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi @mbrunoviegas, This solution contains an issue; kindly refer to #426, which will be resolved shortly. I would appreciate an update on how it turned out! |
Beta Was this translation helpful? Give feedback.
-
I would import Mocked like @omermorad suggested and use |
Beta Was this translation helpful? Give feedback.
-
@mbrunoviegas please refer here: #426 (comment) |
Beta Was this translation helpful? Give feedback.
@mbrunoviegas please refer here: #426 (comment)