{"record":{"id":"4619b9b480914236","repo":"jestjs/jest","slug":"unable-to-forward-jsdom-console-output-neither-s","errorCode":null,"errorMessage":"Unable to forward JSDOM console output - neither sendTo nor forwardTo methods are available","messagePattern":"Unable to forward JSDOM console output - neither sendTo nor forwardTo methods are available","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/jest-environment-jsdom-abstract/src/index.ts","lineNumber":68,"sourceCode":"    const {JSDOM, ResourceLoader, VirtualConsole} = jsdomModule;\n\n    const virtualConsole = new VirtualConsole();\n\n    if (\n      'forwardTo' in virtualConsole &&\n      typeof virtualConsole.forwardTo === 'function'\n    ) {\n      // JSDOM 27+ uses `forwardTo`\n      virtualConsole.forwardTo(context.console);\n    } else if (\n      'sendTo' in virtualConsole &&\n      typeof virtualConsole.sendTo === 'function'\n    ) {\n      // JSDOM 26 uses `sendTo`\n      virtualConsole.sendTo(context.console, {omitJSDOMErrors: true});\n    } else {\n      // Fallback for unexpected API changes\n      throw new TypeError(\n        'Unable to forward JSDOM console output - neither sendTo nor forwardTo methods are available',\n      );\n    }\n\n    virtualConsole.on('jsdomError', error => {\n      context.console.error(error);\n    });\n\n    this.dom = new JSDOM(\n      typeof projectConfig.testEnvironmentOptions.html === 'string'\n        ? projectConfig.testEnvironmentOptions.html\n        : '<!DOCTYPE html>',\n      {\n        pretendToBeVisual: true,\n        resources:\n          typeof projectConfig.testEnvironmentOptions.userAgent === 'string'\n            ? new ResourceLoader({\n                userAgent: projectConfig.testEnvironmentOptions.userAgent,","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/jestjs/jest/blob/8e6d128e4a278059ecddecaa97400b04c8ae5fd9/packages/jest-environment-jsdom-abstract/src/index.ts#L50-L86","documentation":"Thrown by the JSDOM environment constructor when the JSDOM VirtualConsole instance has neither a `forwardTo` method (JSDOM 27+) nor a `sendTo` method (JSDOM 26). This is a version-compatibility safety net — the abstract environment supports both API shapes and throws only if neither is found, indicating an unrecognized JSDOM version.","triggerScenarios":"Installing a JSDOM version that changed or removed both `VirtualConsole.sendTo` and `VirtualConsole.forwardTo`. Using a non-standard jsdom fork. The abstract base class is instantiated with a jsdom module that has an incompatible API surface.","commonSituations":"Upgrading or downgrading `jsdom` independently of `jest-environment-jsdom`. Using a beta or experimental JSDOM release. A package manager resolution conflict pulling an unexpected jsdom version.","solutions":["Pin `jsdom` to a version known to work with your Jest version (check jest-environment-jsdom's peerDependencies).","Run `npm ls jsdom` or `yarn why jsdom` to find conflicting versions.","If using a custom jsdom module, ensure it exposes either `VirtualConsole.forwardTo` or `VirtualConsole.sendTo`."],"exampleFix":"// before: package.json allows any jsdom\n\"devDependencies\": { \"jsdom\": \"latest\" }\n\n// after: pin compatible version\n\"devDependencies\": { \"jsdom\": \"^27.0.0\" }","handlingStrategy":"validation","validationCode":"// Verify jsdom version compatibility before running tests\nfunction checkJsdomVersion() {\n  const jsdom = require('jsdom');\n  const vc = new jsdom.VirtualConsole();\n  if (typeof vc.forwardTo !== 'function' && typeof vc.sendTo !== 'function') {\n    throw new Error('Installed jsdom version is incompatible with jest-environment-jsdom');\n  }\n}","typeGuard":"function hasConsoleForwarding(vc: unknown): vc is { forwardTo: Function } | { sendTo: Function } {\n  return typeof (vc as any)?.forwardTo === 'function' || typeof (vc as any)?.sendTo === 'function';\n}","tryCatchPattern":null,"preventionTips":["Pin jsdom to the version recommended by your jest-environment-jsdom release.","Run `npm ls jsdom` regularly to detect version conflicts.","Avoid installing jsdom globally or as a transitive dependency from unexpected sources."],"tags":["jest-environment-jsdom","version-compatibility","jsdom","configuration"],"backgroundTag":null,"analyzedSha":"8e6d128e4a278059ecddecaa97400b04c8ae5fd9","analyzedAt":"2026-08-10T18:11:27.960Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}