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

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

Comments

Loading...