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
BaseJSDOMEnvironment routes JSDOM's VirtualConsole to Jest's console by calling `forwardTo` (JSDOM 27+) or `sendTo` (JSDOM 26). If the loaded jsdom module's VirtualConsole exposes neither method, the environment cannot forward browser console output and throws at index.ts:68 rather than silently dropping logs.
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 f49721c78e)
Solutions
- Upgrade `jest-environment-jsdom` to a version matching your jsdom major (jsdom 27 needs the forwardTo-aware adapter).
- Pin `jsdom` to a supported major (26 or 27) in resolutions/overrides.
- If you ship a custom jsdom shim, implement `forwardTo(console)` or `sendTo(console)` on its VirtualConsole.
- Run `npm ls jsdom` to find the conflicting copy and dedupe.
Example fix
// before (package.json)
"devDependencies": {
"jest-environment-jsdom": "^30",
"jsdom": "^21"
}
// after
"devDependencies": {
"jest-environment-jsdom": "^30",
"jsdom": "^27"
} Defensive patterns
Strategy: validation
Validate before calling
const jsdom = require('jsdom');
const vc = new jsdom.VirtualConsole();
if (typeof vc.forwardTo !== 'function' && typeof vc.sendTo !== 'function') {
throw new Error(`jsdom ${require('jsdom/package.json').version} is unsupported by this adapter`);
} Type guard
const supportsForwarding = (vc: any): boolean => typeof vc.forwardTo === 'function' || typeof vc.sendTo === 'function';
Prevention
- Pin jsdom to a major supported by jest-environment-jsdom.
- Run `npm ls jsdom` after dependency changes.
- Keep jest-environment-jsdom and jsdom versions in lockstep.
When it happens
Trigger: Loading a jsdom version older than 26 (no sendTo/forwardTo), a fork/stub of jsdom, or a future jsdom that renames the API again. Triggered at environment construction time, before any test runs.
Common situations: Pinning a very old `jsdom` in package.json while using a newer `jest-environment-jsdom`; a yarn/npm resolution that pulls a different jsdom major; a custom environment that injects a mock jsdom module; jsdom releases a new major and the abstract adapter has not been updated yet.
Related errors
- JSDOM did not return a Window object
- Custom export conditions specified but they are not an array
- Custom export conditions specified but they are not an array
AI-assisted analysis of jestjs/jest@f49721c78e (2026-08-03).
Data as JSON: /data/errors/4619b9b480914236.json.
Report an issue: GitHub.