qerrors
Version:
Intelligent error handling middleware with AI-powered analysis, environment validation, caching, and production-ready logging. Provides OpenAI-based error suggestions, queue management, retry mechanisms, and comprehensive configuration options for Node.js
37 lines (32 loc) • 1.12 kB
text/typescript
// jest-setup.ts - Jest setup for TypeScript ESM with React support
// Keep qtests setup FIRST to ensure global stubbing is active
import 'qtests/setup';
import { jest as jestFromGlobals } from '@jest/globals';
// Set test environment early
process.env.NODE_ENV = 'test';
// Resolve jest reference safely and expose globally for tests using jest.*
const J = (typeof jestFromGlobals !== 'undefined' && jestFromGlobals)
? jestFromGlobals
: (globalThis as any).jest;
if (!(globalThis as any).jest && J) {
(globalThis as any).jest = J as any;
}
// Provide CommonJS-like require for ESM tests that call require()
// Avoid top-level await to satisfy stricter Jest transform pipelines.
try {
if (!(globalThis as any).require && typeof require === 'function') {
(globalThis as any).require = require as any;
}
} catch {}
beforeAll(() => {
const j = (globalThis as any).jest || J;
if (j && typeof j.setTimeout === 'function') {
j.setTimeout(10000);
}
});
afterEach(() => {
const j = (globalThis as any).jest || J;
if (j && typeof j.clearAllMocks === 'function') {
j.clearAllMocks();
}
});