Created
August 26, 2023 06:27
-
-
Save sureshvv/3c9825040be95692ae50181f537c9b39 to your computer and use it in GitHub Desktop.
vi.spyOn does not work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
==== example.js ==== | |
function sub1() { | |
return 'hello' | |
} | |
function main1() { | |
return sub1() | |
} | |
export { sub1, main1 } | |
==== example.test.js ==== | |
import { describe, expect, it, vi } from "vitest"; | |
import * as api from './example' | |
describe('main', () => { | |
it("example", () => { | |
const spy1 = vi.spyOn(api, 'sub1') | |
api.main1() | |
expect(spy1).toHaveBeenCalledTimes(1) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment