-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support autospy in the browser
- Loading branch information
1 parent
f85c808
commit d32ab38
Showing
6 changed files
with
80 additions
and
31 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { expect, test, vi } from 'vitest' | ||
import { calculator } from './src/calculator' | ||
import * as mocks_calculator from './src/mocks_calculator' | ||
|
||
vi.mock('./src/calculator', { spy: true }) | ||
vi.mock('./src/mocks_calculator', { spy: true }) | ||
|
||
test('correctly spies on a regular module', () => { | ||
expect(calculator('plus', 1, 2)).toBe(3) | ||
expect(calculator).toHaveBeenCalled() | ||
}) | ||
|
||
test('spy options overrides __mocks__ folder', () => { | ||
expect(mocks_calculator.calculator('plus', 1, 2)).toBe(3) | ||
expect(mocks_calculator.calculator).toHaveBeenCalled() | ||
}) |