Files
metabuilder/pastebin/jest.setup.ts
johndoe6345789 73c8e3d4dc feat: Add snippet-pastebin application
Full-featured pastebin application with:
- Next.js frontend with TypeScript
- Express backend with SQLite/PostgreSQL
- Syntax highlighting for 100+ languages
- Code quality validation system
- Comprehensive accessibility (WCAG compliance)
- Docker deployment configuration
- Playwright E2E tests
- Jest unit tests

This provides a standalone web application that can be
integrated as a capability module in the Universal Platform.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 16:54:54 +00:00

76 lines
1.6 KiB
TypeScript

import '@testing-library/jest-dom'
import React from 'react'
// Make React globally available for components that may reference it
global.React = React
// Mock import.meta for Vite compatibility
Object.defineProperty(globalThis, 'import', {
value: {
meta: {
env: {
DEV: false,
PROD: true,
SSR: false,
},
},
},
})
// Mock Next.js router
jest.mock('next/router', () => ({
useRouter: () => ({
push: jest.fn(),
pathname: '/',
query: {},
asPath: '/',
}),
}))
// Mock Next.js navigation
jest.mock('next/navigation', () => ({
useRouter: () => ({
push: jest.fn(),
replace: jest.fn(),
prefetch: jest.fn(),
}),
usePathname: () => '/',
useSearchParams: () => new URLSearchParams(),
useParams: () => ({}),
}))
// Mock window.matchMedia
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(),
removeListener: jest.fn(),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
})
// Suppress console errors in tests unless explicitly needed
const originalError = console.error
beforeAll(() => {
console.error = (...args: unknown[]) => {
if (
typeof args[0] === 'string' &&
(args[0].includes('Warning: ReactDOM.render') ||
args[0].includes('Warning: useLayoutEffect') ||
args[0].includes('Not implemented: HTMLFormElement.prototype.submit'))
) {
return
}
originalError.call(console, ...args)
}
})
afterAll(() => {
console.error = originalError
})