I am using owl.carousel package in my application and testing it using jest my file is running fine but when i run the test case i get the following error
my code file › encountered a declaration exception
test case error on require file
fit("save button functionality",async ()=>{
let { addDevice } = require('./codeFile')
// $.fn.owlCarousel = jest.fn().mockImplementation(()=>{
// console.log('using my owl carousel');
// })
let addDeviceButton = document.getElementsByClassName("button-link")[0];
await addDevice(addAnotherDeviceButton);
})
getting error on require of code file
package.json
{
"@testing-library/dom": "^6.11.0",
"@testing-library/jest-dom": "^5.16.5",
"jest": "^25.0.0",
"owl.carousel": "^2.3.4",
"jest-environment-jsdom": "^25.0.0",
"jest": {
"testEnvironment": "jsdom",
"coverageThreshold": {
"global": {
"branches": 50,
"functions": 50,
"lines": 50,
"statements": 50
}
},
"transform": {
"^.+\\.js$": "babel-jest",
".+\\.(css|scss|png|jpg|svg)$": "jest-transform-stub"
}
}
}
I understand from my analysis that owlCarousel is a prototype function being added on jquery and in the code $.fn.owlCarousel it is saying $ is undefined
but why is that happening ?