Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

jest.setup.ts 695 B

You have to be logged in to leave a comment. Sign In
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
  1. import { rm } from 'fs/promises';
  2. import nock from 'nock';
  3. import { TEST_CONFIG_DIR } from './.jest/setEnvVars';
  4. jest.mock('./src/logger');
  5. jest.mock('./src/globalConfig/globalConfig');
  6. // Configure nock
  7. beforeAll(() => {
  8. // Disable all real network requests
  9. nock.disableNetConnect();
  10. // Allow localhost connections for tests
  11. nock.enableNetConnect((host) => {
  12. return host.includes('127.0.0.1') || host.includes('localhost');
  13. });
  14. });
  15. afterAll(async () => {
  16. // Clean up nock
  17. nock.cleanAll();
  18. nock.enableNetConnect();
  19. // Clean up test directory
  20. try {
  21. await rm(TEST_CONFIG_DIR, { recursive: true });
  22. } catch {
  23. // Ignore error if directory doesn't exist
  24. }
  25. });
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...