mirror of
https://github.com/supabase/supabase.git
synced 2026-10-14 13:49:09 +03:00
* Update studio testing setup files Improves API mocking type safety and polyfills browser APIs necessary to run tests with framer-motion components * fix missing listen call for msw, resolve test type error * fix imports * Update studio testing setup files Improves API mocking type safety and polyfills browser APIs necessary to run tests with framer-motion components * fix missing listen call for msw, resolve test type error * fix imports * Move non-layout Storage related components to `components/interfaces` * Fix paths --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { TextDecoder, TextEncoder } from 'node:util'
|
|
import { ReadableStream, TransformStream } from 'node:stream/web'
|
|
import { vi } from 'vitest'
|
|
import { configMocks } from 'jsdom-testing-mocks'
|
|
import { act } from '@testing-library/react'
|
|
|
|
configMocks({ act })
|
|
|
|
// Warning: `restoreMocks: true` in vitest.config.ts will
|
|
// cause this global mockImplementation to be **reset**
|
|
// before any tests are run!
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
writable: true,
|
|
value: vi.fn().mockImplementation((query) => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: vi.fn(), // deprecated
|
|
removeListener: vi.fn(), // deprecated
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
dispatchEvent: vi.fn(),
|
|
})),
|
|
})
|
|
|
|
Object.defineProperties(globalThis, {
|
|
TextDecoder: { value: TextDecoder },
|
|
TextEncoder: { value: TextEncoder },
|
|
CSS: {
|
|
value: {
|
|
supports: (_k: any, _v: any) => false,
|
|
escape: (v: any) => v,
|
|
},
|
|
},
|
|
ReadableStream: { value: ReadableStream },
|
|
TransformStream: { value: TransformStream },
|
|
})
|