Closed LoicPoullain closed 3 years ago
ok, here's my perspective: I've used both (in fact I've probably used mocha more than jest), and prefer jest nowadays because:
Altogether Jest is just a better "batteries included" thing. With mocha one has to first make all those boring choices on top and hope they work well together.
Furthermore, while this isn't sooo much of a prio for me, most frontend folks, esp in React, use Jest and using the same testing library for both frontend and backend makes it easier to work on both.
Jest used to be immature and there was a time i definitely preferred mocha, but nowadays Jest my way to go.
I would vote Jest. Just migrated my Foal app from mocha to jest, and the more concise test interface is alone worth it. Haven't yet managed to set it up so it only tests changed files, but this is another reason why it would be better (unsure if mocha has this functionality)
@LoicPoullain I'd prefer Jest. Can you maybe scope the amount of work needed to convert? just in outline form. If it's small enough or reasonable enough maybe one of us (including myself) can give it a go.
Please keep going, been wacthing this all, I haven't used either Mocha or Jest.
Thank you all for sharing your thoughts on this. We can work on adding a --jest
flag to the createapp
command. This would make foal createapp
and foal generate <name>
use jest instead of mocha.
Using a flag has two advantages IMO:
To implement this, I think the best approach would be to go through these steps:
NODE_ENV=e2e
and the unit tests with the env variable NODE_ENV=test
.npm run build:test
, npm run start:test
, npm run test
, npm run build:e2e
, npm run start:e2e
, npm run e2e
).ts-node
for example) because it makes sure there is no difference between the production build that is deployed and the test build that is tested.@jondot you seemed to be interested in contributing on this subject. Do you want to submit a proposition (i.e. a repo)?
Symfony has a very neat functionality called recipes. Maybe instead of adding flags for different tools and setup it would make more sense to enable foal CLI to support a similar feature. This way developers could even bundle foal distros under different recipes. Just to have an example of what Symfony devs achieve with the recipes have a look at API Platform and how it allows you to build a REST API in around 30 minutes.
Seems that this issue is not active anymore. Closing it for now.
Feel free to leave comment if you want to submit a proposal.
I've had several feedback from users preferring "jest" to "mocha". This issue is open so as to start on discussion on this. If you have used both and prefer one, feel free to give your opinion.