UNPKG

@restnfeel/agentc-starter-kit

Version:

한국어 기업용 CMS 모듈 - Task Master AI와 함께 빠르게 웹사이트를 구현할 수 있는 재사용 가능한 컴포넌트 시스템

114 lines (99 loc) 2.63 kB
/** * Jest setup for chatbot module tests */ import "@testing-library/jest-dom"; // Mock console methods to reduce test noise const originalError = console.error; const originalWarn = console.warn; beforeAll(() => { console.error = (...args) => { // Suppress React act warnings in tests if ( args[0] && typeof args[0] === "string" && args[0].includes("Warning: An invalid form control") ) { return; } originalError.call(console, ...args); }; console.warn = (...args) => { // Suppress specific warnings if ( args[0] && typeof args[0] === "string" && (args[0].includes("componentWillReceiveProps") || args[0].includes("componentWillUpdate")) ) { return; } originalWarn.call(console, ...args); }; }); afterAll(() => { console.error = originalError; console.warn = originalWarn; }); // Mock IntersectionObserver global.IntersectionObserver = class IntersectionObserver { constructor() {} disconnect() {} observe() {} unobserve() {} }; // Mock ResizeObserver global.ResizeObserver = class ResizeObserver { constructor() {} disconnect() {} observe() {} unobserve() {} }; // Mock File API global.File = class File { constructor(chunks, filename, options = {}) { this.chunks = chunks; this.name = filename; this.size = chunks.reduce((acc, chunk) => acc + chunk.length, 0); this.type = options.type || ""; this.lastModified = options.lastModified || Date.now(); } text() { return Promise.resolve(this.chunks.join("")); } arrayBuffer() { const buffer = new ArrayBuffer(this.size); let offset = 0; for (const chunk of this.chunks) { const uint8Array = new Uint8Array(buffer, offset, chunk.length); uint8Array.set(new TextEncoder().encode(chunk)); offset += chunk.length; } return Promise.resolve(buffer); } }; // Mock URL.createObjectURL global.URL.createObjectURL = jest.fn(() => "mocked-url"); global.URL.revokeObjectURL = jest.fn(); // Mock fetch global.fetch = jest.fn(); // Extend expect with custom matchers expect.extend({ toBeValidChatbotResponse(received) { const pass = received && typeof received.success === "boolean" && (received.data !== undefined || received.error !== undefined); if (pass) { return { message: () => `expected ${received} not to be a valid chatbot response`, pass: true, }; } else { return { message: () => `expected ${received} to be a valid chatbot response`, pass: false, }; } }, });