1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-22 09:56:51 +01:00
blog/test/vitest.setup.ts
Matthias Kretschmann 05ad0470c2
migrate to biome (#944)
* migrate to biome

* cleanup

* fix

* use tsx

* script tweaks

* fix test runs

* path tweaks
2024-07-27 21:15:05 +01:00

37 lines
1.1 KiB
TypeScript

import { cleanup } from '@testing-library/react'
import { afterEach, vi } from 'vitest'
import balanceMock from './__fixtures__/balance.json'
import * as rainbowkitMock from './__mocks__/@rainbow-me/rainbowkit'
import * as wagmiMock from './__mocks__/wagmi'
import * as wagmiActionsMock from './__mocks__/wagmi/actions'
import '@testing-library/jest-dom'
// viem uses TextEncoder and TextDecoder which are not available with jsdom 16+
import { TextDecoder, TextEncoder } from 'node:util'
Object.assign(global, { TextDecoder, TextEncoder })
Object.defineProperty(window, 'localStorage', {
value: {
getItem: vi.fn(() => null),
removeItem: vi.fn(() => null),
setItem: vi.fn(() => null)
},
writable: true
})
vi.mock('wagmi', () => wagmiMock)
vi.mock('wagmi/actions', () => wagmiActionsMock)
vi.mock('@rainbow-me/rainbowkit', () => rainbowkitMock)
vi.mock('@/features/Web3/hooks/useFetchTokens', () => ({
useFetchTokens: () => ({ isLoading: false, data: balanceMock })
}))
// vi.mock('@/features/Web3/stores', () => ({
// $selectedToken: balanceMock[0],
// $amount: '1'
// }))
afterEach(() => {
cleanup()
})