jestjs/jest · error · Error
pretty-format: Option "theme" must not be null.
Error message
pretty-format: Option "theme" must not be null.
What it means
Error "pretty-format: Option "theme" must not be null." thrown in jestjs/jest.
Source
Thrown at packages/pretty-format/src/index.ts:438
theme: DEFAULT_THEME,
});
function validateOptions(options: OptionsReceived) {
for (const key of Object.keys(options)) {
if (!Object.prototype.hasOwnProperty.call(DEFAULT_OPTIONS, key)) {
throw new Error(`pretty-format: Unknown option "${key}".`);
}
}
if (options.min && options.indent !== undefined && options.indent !== 0) {
throw new Error(
'pretty-format: Options "min" and "indent" cannot be used together.',
);
}
if (options.theme !== undefined) {
if (options.theme === null) {
throw new Error('pretty-format: Option "theme" must not be null.');
}
if (typeof options.theme !== 'object') {
throw new TypeError(
`pretty-format: Option "theme" must be of type "object" but instead received "${typeof options.theme}".`,
);
}
}
}
const getColorsHighlight = (options: OptionsReceived): Colors =>
DEFAULT_THEME_KEYS.reduce((colors, key) => {
const value =
options.theme && options.theme[key] !== undefined
? options.theme[key]
: DEFAULT_THEME[key];
const color = value && (style as any)[value];
if (View on GitHub (pinned to f49721c78e)
Solutions
- Do not pass null for the "theme" option in pretty-format. Either omit the option to use the default theme or pass a theme object with valid ansi-styles keys.
When it happens
Trigger: Thrown at packages/pretty-format/src/index.ts:438 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of jestjs/jest@f49721c78e (2026-08-03).
Data as JSON: /data/errors/f7680098fa91e050.json.
Report an issue: GitHub.