Change from Jasmine, to Mocha/Chai/Sinon

I’ve just ran into exact same situation when moving from Jasmine/Karma to Jest on my current project. Finding every spyOn, which if not preceded with jest. would point to the wrong jasmine global, and no I couldn’t get rid of jasmine right away since it was a step by step port, was a major PITA. Same applies to expect calls which would have the wrong reference to Jasmine etc.

Sadly I think we didn’t really improve too much with the port to Jest, in regards to easier future upgrades. But I think the necessity to import explicitly from chai is one of it’s better features as it will definitely help you if you ever plan to migrate away from Mocha/Chai. Same applies to Sinon.

In general, I feel people are often too used to how it used to be with globals and just stick with that mindset. Let’s be honest, with any decent IDE nowadays pulling in the missing import statements is merely a matter of one or two shortcuts. My avg. APM in Starcraft have been around 170 as a hobby player, and an avg CPM of 460 (https://typing-speed-test.aoeu.eu/) so given that it costs me around 0.5 - 1 seconds which is absolutely affordable for the long-term easier refactoring opportunity :wink:

2 Likes