-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathjest.setup.ts
More file actions
33 lines (28 loc) · 994 Bytes
/
jest.setup.ts
File metadata and controls
33 lines (28 loc) · 994 Bytes
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
import { jest } from '@jest/globals';
import { Supadata } from '@supadata/js';
// Set test timeout
jest.setTimeout(30000);
// Create mock responses
const mockScrapeResponse = '# Test Content';
const mockMapResponse = ['https://example.com/page1', 'https://example.com/page2'];
const mockCrawlResponse = { jobId: 'test-crawl-id' };
const mockCrawlStatusResponse = {
status: 'completed',
data: ['# Page 1 Content', '# Page 2 Content']
};
// Create mock web methods
const mockWeb = {
scrape: jest.fn().mockImplementation(async () => mockScrapeResponse),
map: jest.fn().mockImplementation(async () => mockMapResponse),
crawl: jest.fn().mockImplementation(async () => mockCrawlResponse),
getCrawlResults: jest.fn().mockImplementation(async () => mockCrawlStatusResponse),
};
// Create mock instance
const mockInstance = {
web: mockWeb,
};
// Mock the module
jest.mock('@supadata/js', () => ({
__esModule: true,
Supadata: jest.fn().mockImplementation(() => mockInstance),
}));