skip to Main Content

I am trying to run test in ReactJS project, it is working fine but as soon as I include

import ReactOwlCarousel from 'react-owl-carousel';

I get following error

FAIL  src/App.test.js Test suite failed to run

TypeError: Cannot read properties of undefined (reading 'fn')


>  8 | import ReactOwlCarousel from 'react-owl-carousel';
     | ^
   

  at node_modules/react-owl-carousel/umd/OwlCarousel.js:1758:8
  at node_modules/react-owl-carousel/umd/OwlCarousel.js:1795:7
  at node_modules/react-owl-carousel/umd/OwlCarousel.js:2:85
  at Object.<anonymous> (node_modules/react-owl-carousel/umd/OwlCarousel.js:5:2)
  at Object.<anonymous> (src/App.js:8:1)
  at Object.<anonymous> (src/App.test.js:2:1)
  at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:333:13)
  at runJest (node_modules/@jest/core/build/runJest.js:404:19)

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

I have tried adding adding

<script src="https://code.jquery.com/jquery-3.7.0.slim.min.js"></script>

in index.html but still getting same error

Any type of help is appreciated!

2

Answers


  1. You can mock react-owl-carousel library. There is documentation to Jest:
    Jest Mock docs

    Login or Signup to reply.
  2. import OwlCarousel from 'react-owl-carousel';
    https://www.npmjs.com/package/react-owl-carousel

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search