Open History to see the last commit
1import { vi } from 'vitest'
2import type { MockInstance } from 'vitest'
3β
4/**
5 * Mocks `document.visibilityState` to return a given value.
6 * @param value - The visibility state to return.
7 * @returns The spy, to restore the original getter with `mockRestore()`.
8 */
9export const mockVisibilityState = (
10 value: DocumentVisibilityState,
11): MockInstance<() => DocumentVisibilityState> =>
12 vi.spyOn(document, 'visibilityState', 'get').mockReturnValue(value)