'What difference will DeepMocked make while testing using jest
I am writing unit tests using jest and npm package @golevelup/ts-jest in my nestjs project.
describe("EventHandler", () => {
let shopService: DeepMocked<ShopService>;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [
,
{
provide: "SHOP_SERVICE",
useValue: createMock<ShopService>(),
},
],
}).compile();
shopService = module.get("SHOP_SERVICE");
});
I want to know what difference does it make if i don't use DeepMocked and instead write like this:
describe("EventHandler", () => {
let shopService: ShopService; **---changed here**
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [
,
{
provide: "SHOP_SERVICE",
useValue: createMock<ShopService>(),
},
],
}).compile();
shopService = module.get<ShopService>("SHOP_SERVICE"); **---changed here**
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
