forked from bostrot/telegram-support-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
41 lines (38 loc) · 1.05 KB
/
Copy pathjest.setup.js
File metadata and controls
41 lines (38 loc) · 1.05 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
// Jest setup file - automatically sets up environment for all tests
process.env.NODE_ENV = 'test';
process.env.OPENAI_API_KEY = 'test-key-for-testing';
// Mock fancy-log globally to prevent import issues
jest.mock('fancy-log', () => ({
__esModule: true,
default: jest.fn(),
info: jest.fn(),
error: jest.fn(),
warn: jest.fn(),
debug: jest.fn(),
}));
// Mock OpenAI globally to prevent API key requirements
jest.mock('openai', () => ({
OpenAI: jest.fn().mockImplementation(() => ({
chat: {
completions: {
create: jest.fn().mockResolvedValue({
choices: [
{
message: {
content: 'Mocked OpenAI response',
},
},
],
}),
},
},
})),
}));
// Console warnings during tests can be noise - optionally suppress them
const originalWarn = console.warn;
console.warn = (...args) => {
if (args[0]?.includes?.('Executing command') || args[0]?.includes?.('timed out')) {
return; // Suppress these specific warnings
}
originalWarn(...args);
};