huridocs / uwazi

Uwazi is a web-based, open-source solution for building and sharing document collections
http://www.uwazi.io
MIT License
242 stars 80 forks source link

Update jest to at least 28.1 #4610

Closed LaszloKecskes closed 2 years ago

LaszloKecskes commented 2 years ago

Dependabot opened https://github.com/huridocs/uwazi/pull/4601 to upgrade jest-environment-jsdom. This seems to be a part of an upgrade of the entire jest suite to 28.1.0. Starting 28 jest does not ship with our current test runner (jasmine2), and one has to also separately add the package jest-jasmine2. After updating jest and adding jest-jasmine2, the following error occurs:

k@k-top:~/huridocs/repositories/uwazi$ yarn test app/react/Forms/components/specs/MultiSelect.spec.js
yarn run v1.22.18
$ node --max-http-header-size 20000 ./node_modules/.bin/jest app/react/Forms/components/specs/MultiSelect.spec.js
 FAIL   Client  app/react/Forms/components/specs/MultiSelect.spec.js
  ● Test suite failed to run

    ENOENT: no such file or directory, open '/home/k/huridocs/repositories/uwazi/node_modules/ramda/src/forEach'

      at Runtime.readFile (../node_modules/jest-runtime/build/index.js:2552:21)
      at Object.<anonymous> (../node_modules/html-to-react/lib/parser.js:2:17)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.979 s

That is, the tests cannot resolve a require from html-to-react to ramda. The issue is to research a solution for resolving the error with jasmine2, or try to switch to the default testrunner of jest. The switch would include some development, as we are modifying and using the jasmine global object across our tests.

Additionally, every affected test is a react unit-test (due to html-to-react).

daneryl commented 2 years ago

jest-environment-jsdom and jest were already updated when we updated to node 16, closing.