-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
49 lines (44 loc) · 1.38 KB
/
jest.setup.js
File metadata and controls
49 lines (44 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Purpose: Add Jest DOM matchers and setup test environment
import React from 'react'
import '@testing-library/jest-dom'
// Mock Next.js components
jest.mock('next/image', () => ({
__esModule: true,
default: function Image(props) {
// eslint-disable-next-line jsx-a11y/alt-text, @next/next/no-img-element
const { fill, ...rest } = props
return React.createElement('img', rest)
}
}))
jest.mock('next/link', () => ({
__esModule: true,
default: function Link({ children, href, ...props }) {
return React.createElement('a', { href: href.replace('/producto/', '/produto/'), ...props }, children)
}
}))
// Mock Framer Motion
jest.mock('framer-motion', () => {
return {
__esModule: true,
motion: {
div: ({ children, ...props }) => React.createElement('div', props, children),
span: ({ children, ...props }) => React.createElement('span', props, children)
},
AnimatePresence: ({ children }) => children
}
})
// No text replacement needed - we're using Spanish text
// Mock window.matchMedia
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
})