nestjs
nestjs copied to clipboard
ts-jest - When function is called with a mock, toHaveBeenCalledWith() always succeed even when it should not
it('mock called with another mock', async () => {
class Cheese {
constructor(public name: string) {}
}
class Potato {
private cheese: Cheese;
public applyCheese(cheese: Cheese) {
this.cheese = cheese;
}
}
const mockPotato = createMock<Potato>();
const mockCheese = createMock<Cheese>();
mockPotato.applyCheese(mockCheese);
expect(mockPotato.applyCheese).toHaveBeenCalledTimes(1);
// These all pass, but they should fail because applyCheese wasn't called with these values
expect(mockPotato.applyCheese).toHaveBeenCalledWith('kaboom');
expect(mockPotato.applyCheese).toHaveBeenCalledWith(42);
expect(mockPotato.applyCheese).toHaveBeenCalledWith(null);
// This one should pass (and does)
expect(mockPotato.applyCheese).toHaveBeenCalledWith(mockCheese);
});
Experiencing the same issue. Is there something we can do about it?
Hey @underfisk , any plans on when the package will be updated? The issue is fixed with the merge request #752 Thanks in advance!
Hey @underfisk , any plans on when the package will be updated?
The issue is fixed with the merge request #752
Thanks in advance!
Only @WonderPanda can publish
Just published. This should be available in @golevelup/[email protected]
Thanks a lot man!