Files
workflow-builder/src/setupTests.ts
T
Nikhil-Doye 5ff245f7d8 Add Jest configuration and testing utilities for improved test coverage
- Introduced a Jest configuration file to set up the testing environment with jsdom and TypeScript support.
- Added setupTests.ts to mock localStorage and console methods, enhancing test reliability and reducing noise.
- Implemented comprehensive test cases for llmProcessor and copilotService, ensuring robust functionality and error handling.
- Created unit tests for variable substitution utility, validating correct behavior for various scenarios.
- Enhanced database connection manager tests to cover connection handling and credential validation.
- Established a workflow store test suite to validate workflow management and node/edge operations.
2025-10-20 15:36:35 -04:00

45 lines
1005 B
TypeScript

import "@testing-library/jest-dom";
// Mock localStorage
const localStorageMock = {
getItem: jest.fn(),
setItem: jest.fn(),
removeItem: jest.fn(),
clear: jest.fn(),
};
Object.defineProperty(window, "localStorage", {
value: localStorageMock,
});
// Mock console methods to reduce noise in tests
global.console = {
...console,
// Uncomment to ignore a specific log level
// log: jest.fn(),
// debug: jest.fn(),
// info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
};
// Mock ResizeObserver
global.ResizeObserver = jest.fn().mockImplementation(() => ({
observe: jest.fn(),
unobserve: jest.fn(),
disconnect: jest.fn(),
}));
// Mock IntersectionObserver
global.IntersectionObserver = jest.fn().mockImplementation(() => ({
observe: jest.fn(),
unobserve: jest.fn(),
disconnect: jest.fn(),
}));
// Mock crypto for UUID generation
Object.defineProperty(global, "crypto", {
value: {
randomUUID: () => "mock-uuid-" + Math.random().toString(36).substr(2, 9),
},
});