mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
24 lines
457 B
TypeScript
24 lines
457 B
TypeScript
import { expect, test, vi } from 'vitest'
|
|
import { parent } from './src/nested_parent'
|
|
|
|
const child = vi.hoisted(() => vi.fn())
|
|
|
|
vi.mock(import('./src/nested_child'), () => {
|
|
return {
|
|
child,
|
|
}
|
|
})
|
|
|
|
test('adds', () => {
|
|
child.mockReturnValue(42)
|
|
expect(parent()).toBe(42)
|
|
})
|
|
|
|
test('actual', async () => {
|
|
const { child } = await vi.importActual<
|
|
typeof import('./src/nested_child')
|
|
>('./src/nested_child')
|
|
|
|
expect(child()).toBe(true)
|
|
})
|