We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
vi.spyOn
1 parent 6f79ed1 commit 7c58153Copy full SHA for 7c58153
test/vitest-when.test.ts
@@ -60,6 +60,22 @@ describe('vitest-when', () => {
60
expect(spy()).toEqual(100)
61
})
62
63
+ it('should fall back to original implementation when using a vi.spyOn', () => {
64
+ const calculator = {
65
+ multiplyByTwo(n: number) {
66
+ return 2 * n;
67
+ }
68
69
+
70
+ const spy = vi.spyOn(calculator, 'multiplyByTwo');
71
72
+ expect(spy(2)).toEqual(4)
73
74
+ subject.when(spy).calledWith(1).thenReturn(4)
75
+ expect(spy(1)).toEqual(4)
76
77
+ })
78
79
it('should fall back to original implementation after reset', () => {
80
const spy = vi.fn((n) => 2 * n)
81
0 commit comments