Wednesday, 20 February 2019

Is it possible to write unit tests for select2 using jest?

we have an angular (7) application and we use on some pages the select2 library (select2). I have lately changed the unit test runner from karma to jest. All the tests that contain the select2 component are broken. I have tried to add on setupJest.ts the below line:

global.$.fn.select2 = require('select2');

But nothing happened. The tests throw the below error :

TypeError: Cannot read property 'select2' of undefined

I have not figure out how we could solve this problem.



from Is it possible to write unit tests for select2 using jest?

No comments:

Post a Comment