FoalTS / foal

Full-featured Node.js framework, with no complexity. 🚀 Simple and easy to use, TypeScript-based and well-documented.
https://foalts.org/
MIT License
1.9k stars 140 forks source link

mocha vs jest #629

Closed LoicPoullain closed 3 years ago

LoicPoullain commented 4 years ago

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.

geekflyer commented 4 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.

sinclairnick commented 4 years ago

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)

jondot commented 4 years ago

@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.

anonimusprogramus commented 4 years ago

Please keep going, been wacthing this all, I haven't used either Mocha or Jest.

LoicPoullain commented 4 years ago

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.

Design

Using a flag has two advantages IMO:

Steps

To implement this, I think the best approach would be to go through these steps:

  1. Create a separate repo with an example of a FoalTS project with Jest configuration. This would allow us to discuss the difference possible choices and see how it works in practice.
  2. Once done, we will be able to update the generators with some tests. Version 1.9 refactors a lot of the CLI code so that it will be easier to implement.

Requirements

@jondot you seemed to be interested in contributing on this subject. Do you want to submit a proposition (i.e. a repo)?

EmilCataranciuc commented 4 years ago

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.

LoicPoullain commented 3 years ago

Seems that this issue is not active anymore. Closing it for now.

Feel free to leave comment if you want to submit a proposal.