jestjs/jest · error · TypeError
Unable to forward JSDOM console output - neither sendTo nor…
Error message
Unable to forward JSDOM console output - neither sendTo nor forwardTo methods are available
What it means
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.
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`.
Example fix
// before: package.json allows any jsdom
"devDependencies": { "jsdom": "latest" }
// after: pin compatible version
"devDependencies": { "jsdom": "^27.0.0" } Defensive patterns
Strategy: validation
Validate before calling
// Verify jsdom version compatibility before running tests
function checkJsdomVersion() {
const jsdom = require('jsdom');
const vc = new jsdom.VirtualConsole();
if (typeof vc.forwardTo !== 'function' && typeof vc.sendTo !== 'function') {
throw new Error('Installed jsdom version is incompatible with jest-environment-jsdom');
}
} Type guard
function hasConsoleForwarding(vc: unknown): vc is { forwardTo: Function } | { sendTo: Function } {
return typeof (vc as any)?.forwardTo === 'function' || typeof (vc as any)?.sendTo === 'function';
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Custom export conditions specified but they are not an…
- JSDOM did not return a Window object
- Attempted to display seed but seed value is undefined
- babel-jest: Babel ignores
- Cannot parse as JSON
AI-assisted analysis of jestjs/jest@8e6d128e4a (2026-08-10).
Data as JSON: /api/errors/4619b9b480914236.
Report an issue: GitHub.
Appendix: source
Thrown at packages/jest-environment-jsdom-abstract/src/index.ts:68
const {JSDOM, ResourceLoader, VirtualConsole} = jsdomModule;
const virtualConsole = new VirtualConsole();
if (
'forwardTo' in virtualConsole &&
typeof virtualConsole.forwardTo === 'function'
) {
// JSDOM 27+ uses `forwardTo`
virtualConsole.forwardTo(context.console);
} else if (
'sendTo' in virtualConsole &&
typeof virtualConsole.sendTo === 'function'
) {
// JSDOM 26 uses `sendTo`
virtualConsole.sendTo(context.console, {omitJSDOMErrors: true});
} else {
// Fallback for unexpected API changes
throw new TypeError(
'Unable to forward JSDOM console output - neither sendTo nor forwardTo methods are available',
);
}
virtualConsole.on('jsdomError', error => {
context.console.error(error);
});
this.dom = new JSDOM(
typeof projectConfig.testEnvironmentOptions.html === 'string'
? projectConfig.testEnvironmentOptions.html
: '<!DOCTYPE html>',
{
pretendToBeVisual: true,
resources:
typeof projectConfig.testEnvironmentOptions.userAgent === 'string'
? new ResourceLoader({
userAgent: projectConfig.testEnvironmentOptions.userAgent,View on GitHub (pinned to 8e6d128e4a)