Suppress jsdom XMLHttpRequest errors in Jest tests

- Added `jest.environment.js` to create a custom Jest environment that filters out harmless XMLHttpRequest errors from jsdom's VirtualConsole.
- Updated `jest.config.js` to use the custom environment, reducing noisy test outputs.
This commit is contained in:
Felipe Cardoso
2025-11-26 11:23:56 +01:00
parent 38114b79f9
commit 707315facd
2 changed files with 56 additions and 1 deletions

View File

@@ -8,7 +8,8 @@ const createJestConfig = nextJest({
// Add any custom config to be passed to Jest
const customJestConfig = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
testEnvironment: 'jest-environment-jsdom',
// Custom environment that suppresses jsdom VirtualConsole XMLHttpRequest errors
testEnvironment: '<rootDir>/jest.environment.js',
moduleNameMapper: {
'^next-intl$': '<rootDir>/tests/__mocks__/next-intl.tsx',
'^next-intl/routing$': '<rootDir>/tests/__mocks__/next-intl-routing.tsx',