Capgemini / dcx-react-library

React Library UI/UX agnostic
https://main--6069a6f47f4b9f002171f8e1.chromatic.com
MIT License
113 stars 6 forks source link

the test suite while running raise warning #406

Closed daniele-zurico closed 1 year ago

daniele-zurico commented 1 year ago

while running

yarn test

the output provides quite a lot of warnings like this one:

console.error
      Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot

      38 |   });
      39 |   it('should order ascending', () => {
    > 40 |     const { result } = renderHook(() =>
         |                                  ^
      41 |       useSort(data, { key: 'id', direction: 'ascending' })
      42 |     );
      43 |     act(() => result.current.requestSort('id'));

      at console.error (node_modules/@testing-library/react-hooks/lib/core/console.js:19:7)
      at printWarning (node_modules/react-dom/cjs/react-dom.development.js:86:30)
      at error (node_modules/react-dom/cjs/react-dom.development.js:60:7)
      at Object.render (node_modules/react-dom/cjs/react-dom.development.js:29670:5)
      at node_modules/@testing-library/react-hooks/lib/dom/pure.js:80:18
      at act (node_modules/react/cjs/react.development.js:2512:16)
      at render (node_modules/@testing-library/react-hooks/lib/dom/pure.js:79:26)
      at renderHook (node_modules/@testing-library/react-hooks/lib/core/index.js:114:5)
      at Object.<anonymous> (src/table/__tests__/useSortable.test.tsx:40:34)

the solution should be explained here: https://github.com/testing-library/react-hooks-testing-library#a-note-about-react-18-support

more explicitly:

A Note about React 18 Support If you are using the current version of react-testing-library, replace:

import { renderHook } from '@testing-library/react-hooks'

with

import { renderHook } from '@testing-library/react'

Once replaced, @testing-library/react-hooks can be uninstalled.

daniele-zurico commented 1 year ago

closed by PR #409