-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
54 lines (50 loc) · 1.35 KB
/
jest.setup.js
File metadata and controls
54 lines (50 loc) · 1.35 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
50
51
52
53
54
// Jest Setup
// 🎯 Analogia: O "Setup do Laboratório" - executado ANTES de cada teste
// Aqui você pode adicionar configurações globais, polyfills, etc.
// Configurações globais do DOM
global.ResizeObserver = class ResizeObserver {
constructor() {}
observe() {}
unobserve() {}
disconnect() {}
};
// Mock do HTMLCanvasElement se necessário
if (typeof HTMLCanvasElement !== 'undefined') {
HTMLCanvasElement.prototype.getContext = jest.fn(() => ({
fillRect: jest.fn(),
clearRect: jest.fn(),
getImageData: jest.fn(),
putImageData: jest.fn(),
createImageData: jest.fn(),
setTransform: jest.fn(),
drawImage: jest.fn(),
save: jest.fn(),
fillText: jest.fn(),
restore: jest.fn(),
beginPath: jest.fn(),
moveTo: jest.fn(),
lineTo: jest.fn(),
closePath: jest.fn(),
stroke: jest.fn(),
translate: jest.fn(),
scale: jest.fn(),
rotate: jest.fn(),
arc: jest.fn(),
fill: jest.fn(),
measureText: jest.fn(() => ({ width: 0 })),
transform: jest.fn(),
rect: jest.fn(),
clip: jest.fn(),
}));
}
// Aumenta timeout para testes assíncronos se necessário
jest.setTimeout(10000);
/*
💡 DICA:
Este arquivo é executado uma vez antes de todos os testes.
Use para:
- Configurar mocks globais
- Adicionar matchers customizados
- Configurar bibliotecas de teste
- Adicionar polyfills
*/