obs-ss-plugin-webui/jest.setup.js
Decobus c259f0d943
Some checks failed
Lint and Build / build (20) (pull_request) Failing after 36s
Lint and Build / build (22) (pull_request) Failing after 50s
Add comprehensive performance monitoring and testing infrastructure
- Implement performance dashboard with real-time metrics tracking
- Add React hooks for smart polling, debouncing, and active source lookup
- Create Jest testing framework with comprehensive test suites for components, API endpoints, and utilities
- Enhance UI components with optimized rendering and memoization
- Improve polling efficiency with visibility detection and adaptive intervals

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-19 06:20:19 -04:00

69 lines
No EOL
1.4 KiB
JavaScript

import '@testing-library/jest-dom';
import { TextEncoder, TextDecoder } from 'util';
// Polyfills for Node.js environment
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
// Mock NextResponse for API route testing
jest.mock('next/server', () => ({
NextResponse: {
json: jest.fn((data, options) => ({
data,
status: options?.status || 200,
json: async () => data,
})),
},
}));
// Mock Next.js router
jest.mock('next/navigation', () => ({
useRouter() {
return {
push: jest.fn(),
replace: jest.fn(),
prefetch: jest.fn(),
back: jest.fn(),
forward: jest.fn(),
refresh: jest.fn(),
};
},
useParams() {
return {};
},
usePathname() {
return '';
},
useSearchParams() {
return new URLSearchParams();
},
}));
// Mock window.confirm for delete operations
global.confirm = jest.fn(() => true);
// Mock console.error to avoid noise in tests
const originalError = console.error;
beforeAll(() => {
console.error = (...args) => {
if (
typeof args[0] === 'string' &&
args[0].includes('Warning: ReactDOM.render is no longer supported')
) {
return;
}
originalError.call(console, ...args);
};
});
afterAll(() => {
console.error = originalError;
});
// Mock fetch globally
global.fetch = jest.fn();
// Reset all mocks between tests
beforeEach(() => {
jest.clearAllMocks();
});