koel/resources/assets/js/__tests__/setup.ts

39 lines
854 B
TypeScript
Raw Normal View History

declare global {
interface Window {
BASE_URL: string;
}
}
import vueSnapshotSerializer from 'jest-serializer-vue'
2022-07-10 14:19:11 +00:00
import { expect, vi } from 'vitest'
import Axios from 'axios'
expect.addSnapshotSerializer(vueSnapshotSerializer)
2022-07-10 14:19:11 +00:00
global.ResizeObserver = global.ResizeObserver ||
vi.fn().mockImplementation(() => ({
disconnect: vi.fn(),
observe: vi.fn(),
unobserve: vi.fn()
}))
2022-07-22 16:59:28 +00:00
HTMLMediaElement.prototype.load = vi.fn()
HTMLMediaElement.prototype.play = vi.fn()
HTMLMediaElement.prototype.pause = vi.fn()
2022-07-24 11:47:18 +00:00
HTMLDialogElement.prototype.show = vi.fn(function mock () {
this.open = true
})
HTMLDialogElement.prototype.showModal = vi.fn(function mock () {
this.open = true
})
HTMLDialogElement.prototype.close = vi.fn(function mock () {
this.open = false
})
window.BASE_URL = 'http://test/'
Axios.defaults.adapter = vi.fn()