More of a general JS question than Pact specifical...
# pact-js
m
More of a general JS question than Pact specifically. I'm pretty new to JS so pretty much zero experience testing with it. Are there any general preferences of Jest vs Mocha? (or anything else?). With a focus on nice with Pact ofc, if there are any preferences of working with one over the other. I'm currently working with Vue3+Quasar, bdd makes me happy ๐Ÿ˜€
m
I think jest is the current most used due primarily to react
Tim recently released a mocha interface for Pact which matches the jest pact functionality
m
Yeah, I saw mocha examples in there ๐Ÿค”
๐Ÿ‘ 1
React, Jest, FB eugh
m
I don't know if they use the new mocha specific library or just mocha directly
m
Do you know if that was because fun or much demand? ๐Ÿค”
m
Mocha is pretty popular (by downloads) but Iโ€™d say the majority start with Jest.
y
Mocha is an incredibly popular and powerful testing framework and has been around for many many years. Jest has been gaining in popularity and traction for many reasons, but part of its explosion was around it being bundled with create react app out of the box. I remember when it first came onto the scene, we have cheat sheets between mocha and jest examples to help people transition. Also Mocha/chai is used as the assertion engine in several bigger tools aswell, such as Cypress. So I wouldnโ€™t discount support for one of the other.
m
FWIW I use mocha by default - it goes nice with Chai ๐Ÿ™‚
(personally, I like the combination of chai+mocha, the fluent assertions are really nice). I found Jest awkward, but have accepted itโ€™s the most used
m
Mocha sounds like maybe better, especially if going towards cypress as well then?
Sounds good, I will give mocha a try then, thanks! ๐Ÿ˜€
I do prefer the names but it didn't seem like a good reason for choice in itself ๐Ÿ˜‚
I do like a chai steamer from AMT
๐Ÿ˜… 1
โ˜•โ˜•โ˜•
@Yousaf Nabi (pactflow.io) Need to pick one or the other, at least with which to try out first ๐Ÿ™‚ so much to read. Also I'm behind schedule, this was needed to measure when I need to water my plants as in away this week but it wasn't quite ready in time ๐Ÿ˜‚๐Ÿ˜‚
y
These are some decent cheat sheets out there https://gist.github.com/yoavniran/1e3b0162e1545055429e So mocha is a test runner chai is an assertion engine sinon is used for mocking lolex for date/time mocking everyone used mocha as the test runner and then plugged in whatever they needed. Jest provides a runner, with an assertion engine built in. They are nearly the same with some caveats. the cheat sheets will help massively If you were using a create-react-app I would suggest jest-pact as jest ships out the box with cra. both have good support, Mocha has been around for like eons compared to Jest, so is very robust by now. I switch projects to jest now, unless they are deeply embedded, because it keeps the backend and front end unit testing frameworks the same ๐Ÿ‘
mocha+chai or jest. Personally just go for jest, it will have everything you need out the box, need to reduce that cognitive load hehe
m
Nod. I ofc have to go for something a little less mainstream so skipped react ๐Ÿ˜€
๐Ÿ˜† 1
Ahh names. My BE is going to be python You wouldn't mocha for the BE? I did not see that ๐Ÿค”
Hmm interesting about switching projects ๐Ÿค” that would make sense if you have two different and could have two the same though
y
last project where I got introduced to Jest, it was TypeScript across the board. Mocha is JS land, so you would pick a suitable testing framework for Python. I think PyTest is most peoples go to. We wrote a few python scripts and used moto to mock out aws services
m
Yeah I've got python covered, JS is the new land ๐Ÿ˜€
Can you folk do BDD yet? ๐Ÿ˜€
Moto is insane. Mock an ec2 instance. What does that even mean ๐Ÿ˜ฎ๐Ÿ˜ฎ
i
the auto-mock feature of jest is pretty awesome - but for pact testing basically useless.
๐Ÿ˜† 1
๐Ÿ‘ 1