Spaces:
Sleeping
Sleeping
Download frontend-backup/src/setupTests.ts from edichat/edi.chat.test: direct link, hf CLI and curl.
- Browser
- Download file 1.81 kB
-
https://huggingface.co/spaces/edichat/edi.chat.test/resolve/main/frontend-backup/src/setupTests.ts
- Command line
-
hf download hf://spaces/edichat/edi.chat.test/frontend-backup/src/setupTests.ts
-
curl -L -o setupTests.ts https://huggingface.co/spaces/edichat/edi.chat.test/resolve/main/frontend-backup/src/setupTests.ts
1.81 kB
| // jest-dom adds custom jest matchers for asserting on DOM nodes. | |
| // allows you to do things like: | |
| // expect(element).toHaveTextContent(/react/i) | |
| // learn more: https://github.com/testing-library/jest-dom | |
| import '@testing-library/jest-dom'; | |
| // Mock window.matchMedia | |
| Object.defineProperty(window, 'matchMedia', { | |
| writable: true, | |
| value: jest.fn().mockImplementation(query => ({ | |
| matches: false, | |
| media: query, | |
| onchange: null, | |
| addListener: jest.fn(), // deprecated | |
| removeListener: jest.fn(), // deprecated | |
| addEventListener: jest.fn(), | |
| removeEventListener: jest.fn(), | |
| dispatchEvent: 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 HTMLCanvasElement.getContext | |
| HTMLCanvasElement.prototype.getContext = jest.fn(); | |
| // Suppress console warnings during tests | |
| const originalError = console.error; | |
| beforeAll(() => { | |
| console.error = (...args) => { | |
| if ( | |
| typeof args[0] === 'string' && | |
| args[0].includes('Warning: ReactDOM.render is deprecated') | |
| ) { | |
| return; | |
| } | |
| originalError.call(console, ...args); | |
| }; | |
| }); | |
| afterAll(() => { | |
| console.error = originalError; | |
| }); | |
| // Mock localStorage | |
| const localStorageMock = { | |
| getItem: jest.fn(), | |
| setItem: jest.fn(), | |
| removeItem: jest.fn(), | |
| clear: jest.fn(), | |
| }; | |
| global.localStorage = localStorageMock; | |
| // Mock sessionStorage | |
| const sessionStorageMock = { | |
| getItem: jest.fn(), | |
| setItem: jest.fn(), | |
| removeItem: jest.fn(), | |
| clear: jest.fn(), | |
| }; | |
| global.sessionStorage = sessionStorageMock; |