Fix: “Error: Test environment jest-environment-jsdom cannot be found”

Are you trying the upgrade jest version to jest latest version?

Then you should get the error “Error: Test environment jest-environment-jsdom cannot be found. Make sure the testEnvironment configuration option points to an existing node module.

Now team added more descriptive error on version 28.0.1 when you trying to upgrade jest version “Error: …
As of Jest 28 “jsdom” is no longer shipped by default, make sure to install it separately.”

How to Fix “Error: Test environment jest-environment-jsdom cannot be found”?

To fix “Error: Test environment jest-environment-jsdom cannot be found. Make sure the testEnvironment configuration option points to an existing node module“, you have to install jsdom package because jsdom don’t come default , you have to install it separately.

To install jsdom package , run below npm command:

npm install --save-dev jest-environment-jsdom

After running the above command or installing jsdom package your error will be resolved.

How to Fix “As of Jest 28 “jsdom” is no longer shipped by default, make sure to install it separately” Error?

To fix “As of Jest 28 “jsdom” is no longer shipped by default, make sure to install it separately“, you have to install jsdom package because jsdom don’t come default , you have to install it separately.

This error is added in jest version 28.0.1, to make it more descriptive and understandable.

To install jsdom package , run below npm command:

npm install --save-dev jest-environment-jsdom

After running the above command or installing jsdom package your error will be resolved.