Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with Toast component when Testing #3063

Closed
3 of 10 tasks
zeenatbaig opened this issue Feb 27, 2024 · 2 comments
Closed
3 of 10 tasks

Error with Toast component when Testing #3063

zeenatbaig opened this issue Feb 27, 2024 · 2 comments
Labels
component: toast testing type: bug 🪲 Something isn't working type: documentation Improvements or additions to documentation

Comments

@zeenatbaig
Copy link

Package name(s)

Core (@salt-ds/core)

Package version(s)

"@salt-ds/core": "^1.15.0",

Description

Im running some jest tests with the toast component and im getting the following error
TypeError: _a.scrollIntoView is not a function

at node_modules/@salt-ds/core/dist-cjs/src/toast/Toast.tsx:40:23
at commitHookEffectListMount (node_modules/react-dom/cjs/react-dom.development.js:20573:26)
at commitLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:20634:11)
at commitLayoutEffects (node_modules/react-dom/cjs/react-dom.development.js:23426:7)
at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:3945:14)
at HTMLUnknownElement.callTheUserObjectsOperation (node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30)
at innerInvokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:350:25)
at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:286:3)
at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:233:9)
at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:104:17)
at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:241:34)
at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:3994:16)
at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:4056:31)
at commitRootImpl (node_modules/react-dom/cjs/react-dom.development.js:23151:9)
at unstable_runWithPriority (node_modules/scheduler/cjs/scheduler.development.js:468:12)
at runWithPriority$1 (node_modules/react-dom/cjs/react-dom.development.js:11276:10)
at commitRoot (node_modules/react-dom/cjs/react-dom.development.js:22990:3)
at performSyncWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:22329:3)
at node_modules/react-dom/cjs/react-dom.development.js:11327:26
at unstable_runWithPriority (node_modules/scheduler/cjs/scheduler.development.js:468:12)
at runWithPriority$1 (node_modules/react-dom/cjs/react-dom.development.js:11276:10)
at flushSyncCallbackQueueImpl (node_modules/react-dom/cjs/react-dom.development.js:11322:9)
at flushSyncCallbackQueue (node_modules/react-dom/cjs/react-dom.development.js:11309:3)
at batchedUpdates$1 (node_modules/react-dom/cjs/react-dom.development.js:22387:7)
at act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:1042:14)
at Object.eventWrapper (node_modules/@testing-library/react/dist/pure.js:65:28)
at fireEvent (node_modules/@testing-library/dom/dist/events.js:16:35)
at Function.fireEvent. [as change] (node_modules/@testing-library/dom/dist/events.js:125:36)
at Function.fireEvent. [as change] (node_modules/@testing-library/react/dist/fire-event.js:18:52)

Steps to reproduce

Im using toast within a combo box from the jpmuitk. When the toast is popping up. The tests throw that error

Expected behavior

pass the test without throwing an error

Operating system

  • macOS
  • Windows
  • Linux
  • iOS
  • Android

Browser

  • Chrome
  • Safari
  • Firefox
  • Edge

Are you a JPMorgan Chase & Co. employee?

  • I am an employee of JPMorgan Chase & Co.
@zeenatbaig zeenatbaig added status: awaiting triage Automatically added to new issues. Should be removed once they have been triaged. type: bug 🪲 Something isn't working labels Feb 27, 2024
@origami-z
Copy link
Contributor

jsdom doesn't support this, try the setup suggested here

Element.prototype.scrollIntoView = jest.fn(); 

@origami-z origami-z added type: documentation Improvements or additions to documentation testing component: toast and removed status: awaiting triage Automatically added to new issues. Should be removed once they have been triaged. labels Feb 27, 2024
@origami-z
Copy link
Contributor

This is no longer an issue given scrollIntoView is removed from Toast in #3038.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: toast testing type: bug 🪲 Something isn't working type: documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants