Jest Configuration Error
Error message
Jest: Configuration error — invalid option in jest.config.js
Quick summary
jest.config.js or the Jest config in package.json has an invalid setting, causing Jest to fail before running any tests.
Why this happens
A typo in a configuration option name.
Using a deprecated option that was removed in a newer Jest version.
Invalid value type for an option (e.g., string where array is expected).
Conflicting options that can't be used together.
Minimal example
// jest.config.js
module.exports = {
testEnviroment: 'jsdom', // typo — should be testEnvironment
};// jest.config.js
module.exports = {
testEnvironment: 'jsdom', // correct spelling
};Fix the typo in the configuration option name.
How to diagnose
Read the error message — Jest usually says which option is invalid.
Check the Jest documentation for the correct option name and value type.
Compare with a known working Jest configuration.
Check the Jest version — options may have changed between versions.
How to fix
Fix the typo or invalid option name.
Update to the correct option name for your Jest version.
Fix the value type (e.g., use an array instead of a string).
Remove deprecated options and use their replacements.
How to prevent
Refer to the Jest documentation for your specific version.
Keep Jest updated and check migration guides for breaking changes.
Use a minimal, well-tested configuration as a starting point.
Related Resources
Related Glossary
Related Lessons
- Jest Basics
Getting started with Jest.