Skip to content

Error: Not implemented: window.scrollTo. How do we remove this error from Jest test?

The error:

console.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
      Error: Not implemented: window.scrollTo
          at module.exports (/Users/me/Projects/my-project/node_modules/jsdom/lib/jsdom/browser/not-implemented.js:9:17)
          at /Users/me/Projects/my-project/node_modules/jsdom/lib/jsdom/browser/Window.js:594:7

Because we are using window.scrollTo(0,0).

Also getting Not implemented Navigation for:

window.location.replace(externa_link) same error happens with .assign.

I tried googling for solutions with react-router, but all examples use some component which contains window.location.

Is there a way to avoid this error? Or hide it?

I did some research and found that the Facebook team isn’t going to address it. Is there a way to suppress these errors/warnings when running jest test?

Our code doesn’t break and all tests pass otherwise.



Try running the jest command with --env=jsdom. This will mock most browser functions and will solve your issues.

There are more ways of setting the test environment, take a look at:


This worked for the window.scrollTo errors

User contributions licensed under: CC BY-SA
9 People found this is helpful