1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-30 21:52:05 +02:00
blog/.jest/setup-test-env.ts

24 lines
732 B
TypeScript
Raw Normal View History

2023-01-29 22:58:19 +01:00
import * as Gatsby from 'gatsby'
2023-08-17 13:43:32 +02:00
import '@testing-library/jest-dom'
2023-01-29 22:58:19 +01:00
import avatar from './__fixtures__/avatar.json'
import github from './__fixtures__/github.json'
import meta from './__fixtures__/meta.json'
import posts from './__fixtures__/posts.json'
2022-11-19 16:09:13 +01:00
import './__mocks__/matchMedia'
2019-11-24 14:29:25 +01:00
2023-08-17 13:43:32 +02:00
// viem uses TextEncoder and TextDecoder which are not available with jsdom 16+
import { TextEncoder, TextDecoder } from 'util'
Object.assign(global, { TextDecoder, TextEncoder })
2019-11-24 14:29:25 +01:00
const useStaticQuery = jest.spyOn(Gatsby, 'useStaticQuery')
beforeAll(() => {
useStaticQuery.mockImplementation(() => ({
...meta,
...avatar,
logo: { edges: [{ node: { relativePath: 'apple-touch-icon.png' } }] },
...posts,
...github
}))
})