question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: _a.scrollTo is not a function (in tests)

See original GitHub issue

I’m submitting a…


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

When creating any Canvas in tests i get an error of TypeError: _a.scrollTo is not a function

For ref here is my code that works just fine in non-test cases:

      <Canvas
        nodes={graph.nodes.map(toReaflowNode(formatNodeLabel))}
        edges={graph.edges.map(toReaflowEdge)}
      />


Full stacktrace

   Error: Uncaught [TypeError: _a.scrollTo is not a function]
        at reportException (/home/cdk/dev/codoc-webapp/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js:62:24)
        at innerInvokeEventListeners (/home/cdk/dev/codoc-webapp/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:333:9)
        at invokeEventListeners (/home/cdk/dev/codoc-webapp/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:274:3)
        at HTMLUnknownElementImpl._dispatch (/home/cdk/dev/codoc-webapp/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:221:9)
        at HTMLUnknownElementImpl.dispatchEvent (/home/cdk/dev/codoc-webapp/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:94:17)
        at HTMLUnknownElement.dispatchEvent (/home/cdk/dev/codoc-webapp/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:231:34)
        at Object.invokeGuardedCallbackDev (/home/cdk/dev/codoc-webapp/node_modules/react-dom/cjs/react-dom.development.js:3994:16)
        at invokeGuardedCallback (/home/cdk/dev/codoc-webapp/node_modules/react-dom/cjs/react-dom.development.js:4056:31)
        at flushPassiveEffectsImpl (/home/cdk/dev/codoc-webapp/node_modules/react-dom/cjs/react-dom.development.js:23574:9)
        at unstable_runWithPriority (/home/cdk/dev/codoc-webapp/node_modules/scheduler/cjs/scheduler.development.js:646:12) TypeError: _a.scrollTo is not a function
        at /home/cdk/dev/codoc-webapp/node_modules/reaflow/dist/index.cjs.js:442:110
        at invokePassiveEffectCreate (/home/cdk/dev/codoc-webapp/node_modules/react-dom/cjs/react-dom.development.js:23487:20)
        at HTMLUnknownElement.callCallback (/home/cdk/dev/codoc-webapp/node_modules/react-dom/cjs/react-dom.development.js:3945:14)
        at HTMLUnknownElement.callTheUserObjectsOperation (/home/cdk/dev/codoc-webapp/node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30)
        at innerInvokeEventListeners (/home/cdk/dev/codoc-webapp/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:318:25)
        at invokeEventListeners (/home/cdk/dev/codoc-webapp/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:274:3)
        at HTMLUnknownElementImpl._dispatch (/home/cdk/dev/codoc-webapp/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:221:9)
        at HTMLUnknownElementImpl.dispatchEvent (/home/cdk/dev/codoc-webapp/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:94:17)
        at HTMLUnknownElement.dispatchEvent (/home/cdk/dev/codoc-webapp/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:231:34)
        at Object.invokeGuardedCallbackDev (/home/cdk/dev/codoc-webapp/node_modules/react-dom/cjs/react-dom.development.js:3994:16)
        at invokeGuardedCallback (/home/cdk/dev/codoc-webapp/node_modules/react-dom/cjs/react-dom.development.js:4056:31)
        at flushPassiveEffectsImpl (/home/cdk/dev/codoc-webapp/node_modules/react-dom/cjs/react-dom.development.js:23574:9)
        at unstable_runWithPriority (/home/cdk/dev/codoc-webapp/node_modules/scheduler/cjs/scheduler.development.js:646:12)
        at runWithPriority$1 (/home/cdk/dev/codoc-webapp/node_modules/react-dom/cjs/react-dom.development.js:11276:10)
        at flushPassiveEffects (/home/cdk/dev/codoc-webapp/node_modules/react-dom/cjs/react-dom.development.js:23447:14)
        at Object.<anonymous>.flushWork (/home/cdk/dev/codoc-webapp/node_modules/react-dom/cjs/react-dom-test-utils.development.js:992:10)
        at act (/home/cdk/dev/codoc-webapp/node_modules/react-dom/cjs/react-dom-test-utils.development.js:1107:9)
        at render (/home/cdk/dev/codoc-webapp/node_modules/@testing-library/react/dist/pure.js:95:26)
        at render (/home/cdk/dev/codoc-webapp/src/_test/react.jsx:21:8)
        at Object.<anonymous> (/home/cdk/dev/codoc-webapp/src/components/GraphWrapper.test.jsx:41:39)
        at Promise.then.completed (/home/cdk/dev/codoc-webapp/node_modules/jest-circus/build/utils.js:276:28)
        at new Promise (<anonymous>)
        at callAsyncCircusFn (/home/cdk/dev/codoc-webapp/node_modules/jest-circus/build/utils.js:216:10)
        at _callCircusTest (/home/cdk/dev/codoc-webapp/node_modules/jest-circus/build/run.js:212:40)
        at processTicksAndRejections (node:internal/process/task_queues:94:5)
        at _runTest (/home/cdk/dev/codoc-webapp/node_modules/jest-circus/build/run.js:149:3)
        at _runTestsForDescribeBlock (/home/cdk/dev/codoc-webapp/node_modules/jest-circus/build/run.js:63:9)
        at _runTestsForDescribeBlock (/home/cdk/dev/codoc-webapp/node_modules/jest-circus/build/run.js:57:9)
        at run (/home/cdk/dev/codoc-webapp/node_modules/jest-circus/build/run.js:25:3)
        at runAndTransformResultsToJestFormat (/home/cdk/dev/codoc-webapp/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:176:21)
        at jestAdapter (/home/cdk/dev/codoc-webapp/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:109:19)
        at runTestInternal (/home/cdk/dev/codoc-webapp/node_modules/jest-runner/build/runTest.js:380:16)
        at runTest (/home/cdk/dev/codoc-webapp/node_modules/jest-runner/build/runTest.js:472:34)
        at Object.worker (/home/cdk/dev/codoc-webapp/node_modules/jest-runner/build/testWorker.js:133:12)

Expected behavior

That something would load for my tests 😃

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Libs:
- react version: 17.0.1
- realayers version: 3.0.14


Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  linux

Others:

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Nerevar123commented, Sep 2, 2021

Adding this line to setupTests.ts fixed the problem:

window.ResizeObserverEntry = jest.fn();

0reactions
amcdnlcommented, Sep 21, 2021

Can any of you retry on latest? I think I solved it but not sure.

Read more comments on GitHub >

github_iconTop Results From Across the Web

scrollTo is not a function - Stack Overflow
I am using Firebug, it says this: "TypeError: $.scrollTo is not a function $. · You mean how all the functions all called...
Read more >
Window.scrollTo is not a function | Selenium Forum
Window.scrollTo is not a function .while using javascript executor in firefox, I am getting an error Window.scrollTo is not a function.
Read more >
Window.scrollTo() - Web APIs | MDN
Window.scrollTo() scrolls to a particular set of coordinates in the document. ... Window.scroll() is effectively the same as this method.
Read more >
Problem: jQuery.scrollTo is not a function - WordPress.org
Seems like it could be something with scroll function in your theme. Uncaught TypeError: Cannot read property 'top' of undefined at HTMLAnchorElement.<anonymous> ...
Read more >
jquery scrollTo not working - SOLVED
Hi! I'm desperatly trying to make the scrollTo plugin work on my website, and so far, no luck... So, that's what I have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found