[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

docs: improve spyOn example with a contextual example (#3185)

authored by

Ben Hong and committed by
GitHub
(Apr 12, 2023, 8:18 PM +0200) aa22f797 29eebf65

+3 -3
+3 -3
docs/api/vi.md
··· 567 567 568 568 ```ts 569 569 let apples = 0 570 - const obj = { 570 + const cart = { 571 571 getApples: () => 13, 572 572 } 573 573 574 - const spy = vi.spyOn(obj, 'getApples').mockImplementation(() => apples) 574 + const spy = vi.spyOn(cart, 'getApples').mockImplementation(() => apples) 575 575 apples = 1 576 576 577 - expect(obj.getApples()).toBe(1) 577 + expect(cart.getApples()).toBe(1) 578 578 579 579 expect(spy).toHaveBeenCalled() 580 580 expect(spy).toHaveReturnedWith(1)