LegacyTabComponent fails to render in unit tests when migrating to iTwinUI 3 #2404
-
Hello, I'm in the process of migrating a package's components from using iTwinUI v2 to v3, there's no visual regressions that I can see when testing the components in a test app, I've updated almost all the tests but I was left with one component that is failing it's unit test. This is the PR I'm working on: iTwin/viewer-components-react#1136. This is the component, it uses the Legacy API of the
I was able to reproduce this error still when switching from using I did try moving over to using the Tabs' Composite API, and the tests pass, but on the other hand the component would break in the test app, with this error: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Thanks for your investigation! I believe you are using JSDOM? If so, Since we also use JSDOM in our vitest unit tests for |
Beta Was this translation helpful? Give feedback.
Thanks for your investigation! I believe you are using JSDOM? If so,
Element.scrollTo()
is not implemented in it. So you'd need to define a function for it or mock it or something similar.Since we also use JSDOM in our vitest unit tests for
Tabs
we have also defined a dummy function forscrollTo
:iTwinUI/packages/itwinui-react/setupTests.ts
Line 8 in 5e31043