mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
By default, all of the tests run in silent mode with monkey-patched the console logging so no console logging will ever appear in test output. This confuses the agent- sometimes it will add console logging to help it debug things, and it won't see the logs that it expects. Adds src/utils/vitest-verbosity.ts to handle verbosity resolution and console logging. Modifies src/vitest.config.ts and webview-ui/vitest.config.ts to integrate the new verbosity control. Removes manual console suppression from src/vitest.setup.ts and webview-ui/vitest.setup.ts as it's now handled dynamically. Co-authored-by: Chris Hasson <noreply@example.com>
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import "@testing-library/jest-dom"
|
|
import "@testing-library/jest-dom/vitest"
|
|
|
|
// Force React into development mode for tests
|
|
// This is needed to enable act(...) function in React Testing Library
|
|
globalThis.process = globalThis.process || {}
|
|
globalThis.process.env = globalThis.process.env || {}
|
|
globalThis.process.env.NODE_ENV = "development"
|
|
|
|
class MockResizeObserver {
|
|
observe() {}
|
|
unobserve() {}
|
|
disconnect() {}
|
|
}
|
|
|
|
global.ResizeObserver = MockResizeObserver
|
|
|
|
// Fix for Microsoft FAST Foundation compatibility with JSDOM
|
|
// FAST Foundation tries to set HTMLElement.focus property, but it's read-only in JSDOM
|
|
// The issue is that FAST Foundation's handleUnsupportedDelegatesFocus tries to set element.focus = originalFocus
|
|
// but JSDOM's HTMLElement.focus is a getter-only property
|
|
Object.defineProperty(HTMLElement.prototype, "focus", {
|
|
get: function () {
|
|
return (
|
|
this._focus ||
|
|
function () {
|
|
// Mock focus behavior for tests
|
|
}
|
|
)
|
|
},
|
|
set: function (value) {
|
|
this._focus = value
|
|
},
|
|
configurable: true,
|
|
})
|
|
|
|
Object.defineProperty(window, "matchMedia", {
|
|
writable: true,
|
|
value: vi.fn().mockImplementation((query) => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: vi.fn(),
|
|
removeListener: vi.fn(),
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
dispatchEvent: vi.fn(),
|
|
})),
|
|
})
|
|
|
|
// Mock scrollIntoView which is not available in jsdom
|
|
Element.prototype.scrollIntoView = vi.fn()
|