0

I am trying to use Jest with a new CRA project, but I am facing a problem when trying to use the findByText function. I installed:

yarn add -D jest-environment-jsdom-sixteen

And run my tests with react-scripts test --env=jest-environment-jsdom-sixteen. It works fine if I do this solution that I encountered while reading these issues here:

However I am also using the Jest plugin from VS code and tests do not pass with it. I have tried to do this in my jest.config.js as suggested in the docs:

module.exports = {
  testEnvironment: 'jest-environment-jsdom-sixteen',
};

But it still does not work.

Thanks in advance.

1 Answer 1

7

Testing MutationObserver with Jest: Try this, it worked for me, on a similar error:

  1. npm i -D mutationobserver-shim
  2. import "mutationobserver-shim"; in setupTests.js

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.