feat: configure Jest testing infrastructure

- Update Jest config with module name mapping for uuid and node-fetch
- Add Babel transform for mixed JS/TS support
- Configure transformIgnorePatterns for ES modules
- Add comprehensive test mocks for uuid and node-fetch
- Setup import.meta environment variables for Jest compatibility
- Increase test timeout to 30 seconds for integration tests
This commit is contained in:
William Valentin
2025-09-07 15:20:59 -07:00
parent 315303b120
commit c5d3631cb6
5 changed files with 185 additions and 5 deletions

View File

@@ -20,10 +20,29 @@ Object.defineProperty(window, 'localStorage', {
// Mock fetch
global.fetch = jest.fn();
// Mock import.meta for Jest
Object.defineProperty(globalThis, 'import', {
value: {
meta: {
env: {
NODE_ENV: 'test',
VITE_COUCHDB_URL: 'http://localhost:5984',
VITE_COUCHDB_USERNAME: 'admin',
VITE_COUCHDB_PASSWORD: 'password',
VITE_MAILGUN_API_KEY: 'test-key',
VITE_MAILGUN_DOMAIN: 'test.mailgun.org',
VITE_MAILGUN_BASE_URL: 'https://api.mailgun.net',
VITE_MAILGUN_FROM_NAME: 'Test App',
VITE_MAILGUN_FROM_EMAIL: 'test@example.com',
},
},
},
});
// Setup console to avoid noise in tests
const originalError = console.error;
beforeAll(() => {
console.error = (...args: any[]) => {
console.error = (...args: unknown[]) => {
if (
typeof args[0] === 'string' &&
args[0].includes('Warning: ReactDOM.render is deprecated')