dxc-technology / halstack-react

Library of components for building SPAs with React and Halstack Design System
https://developer.dxc.com/halstack/
Apache License 2.0
15 stars 14 forks source link

Jest Test - Issue #1537

Closed hanoj-budime closed 1 year ago

hanoj-budime commented 1 year ago

Describe the bug While Jest test case for reactjs, Error

 ReferenceError: ResizeObserver is not defined

Screenshots image

To Reproduce install halstack-react v9 Run

npm run test:ci

Additional context But, For me after adding this worked. Let hear for you that this approach is fine? yes or no


// Runs a function before any of the tests in this file run
beforeAll(() => {
   // something....

   // Worked - solution
  // ? ResizeObserver - added halstack-react v9
    global.ResizeObserver = class ResizeObserver {
      observe() {}
      unobserve() {}
      disconnect() {}
    };

    //....
}
GomezIvann commented 1 year ago

Hi @HanojHanu!

Yes, you are right, that's the solution to this problem. If you take a look at the tests of the components that use this API, they basically do the same. For example, the Select's test file. We are discussing how to address this issue, because Jest is the most common JS testing tool and we want to make the user experience as clean as possible!

Thanks for the feedback 🚀