- Status: accepted
- Deciders: Thomas GERBET, Joris MASSON
- Date: 2022-07-06
Technical Story: request #27548 Introduce Vitest as the new default JS test runner
Tuleap started to use Jest to run the JS unit tests a while ago in replacement of Karma/Jasmine.
Jest is still the de-facto standard in the JS community today. However, in the recent months we started to encounter more frequents pain-points as more JS packages started to deliver only ES Modules. At the same time credible alternatives have emerged and are now mature enough to make them usable in the Tuleap development context.
Our build toolchain has moved to using ESBuild to do the necessary code transpilations/transformations but Jest is still using Babel. This difference and the fact the build toolchain cannot be re-used to run the tests lead to an additional complexity in the overall system.
Chosen option: migrate to Vitest because it makes possible to move past our current pain-points with Jest.
The proposed plan to introduce Vitest into the codebase is as follows:
- new packages: Vitest is used even if Webpack is necessary to build the production bundle.
- existing packages are migrated progressively in this order:
- packages using Vite
- packages using Webpack but have their own
typecheck
task as recommended - packages using Webpack without their own
typecheck
task: they first need to have atypecheck
task (no typechecking will be done in Vitest) and then they can be migrated
The decision might and should be revisited in the future to see if it is still the best available option.
Keep using Jest
- Good, because it is the most common test runner in the JS community
- Good, because it is already what we are using so nothing needs to be done
- Bad, because we will encounter more and more frequent issues with "ESM only" JS packages as seen in our existing configuration. This is not something which can only be attributed to Jest, the support of ESM in the NodeJS world is not really a success story.
- Bad, because we still have to maintain 2 different build configurations for each package (one for Jest and one for building the production code)
- Note: some concerns have been raised regarding the maintenance of Jest in the recent months. Those concerns seem to have been resolved, at least partially, with the move from Meta to the JS Foundation.
Migrate to Vitest
- Good, because it re-uses our build configuration of Vite, no need to maintain 2 different configurations for packages already using Vite
- Good, the "community support" appears to be good and we have a pretty good experience with our usages of Vue and Vite
- Good, the matchers API used by Vitest is compatible with Jest so there is nothing new to learn
- Bad, because we would need to migrate our existing test files. The migration is however far easier than what we experienced when coming from Karma/Jasmine and can be progressive.
- Bad, because the IDE integrations is not yet completely there: there is official support for VS Code and a plugin supported by someone in the community for Jetbrains IDEs but no native support.
- Is influenced by ADR-0018: Choice of JavaScript Bundler