Page MenuHomePhabricator

build: Migrate from Jest to Vitest test-runner
Open, LowestPublic

Description

Background

Vite's CJS Node API is deprecated as of v5 (the current major version). Many other projects in the Vite ecosystem will likely make similar moves.
Also Vue3-Jest hasn't been updated in two years and seems end of life

Goal

Vitest is nowadays the recommended test-runner for use in the Vue ecosystem.
Codex should embrace this ESM-based future by migrating its test suite from Jest (which still only has experimental support for ES Modules) in favor of Vitest. Additionally to overcoming Jest's historically problematic ESM support:

  1. It promises to be API-compatible with Jest
  2. It reuses the Vite config. This could allow us to deduplicate some configuration and transforms (in particular the SVG transform in the icons package), because we wouldn't have to have a separate version of those for Jest anymore.
  3. Jest has slower startup due to its own transformation pipeline, see 2. above
  4. It also promises a watch mode that's essentially HMR but for unit tests using Vite's super-fast transformer + HMR pipeline.

Considerations

  • Is Vitest sustainable choice with it's much lower market share than Vite?

@Novem_Linguae brought up this question in 2022, the 2024 stats are also available at https://raygun.com/blog/javascript-unit-testing-frameworks/#vitest

Further information

Event Timeline

Vitest doesn't appear to have much market share. It looks like as of 2022 it was rated 11th most popular, if this is accurate.

Jest of course is the # 1 most popular outside of the mediawiki ecosystem.

I would argue that there are some good advantages to preferring "popular" software such as Jest:

  • ease of onboarding (the software engineer might already know it)
  • more frequent library patches
  • doesn't become abandonware as quickly

Whatever is decided here, I just wanted to point this out. QUnit has low market share and so does Vitest. Jest might be an opportunity for mediawiki to standardize around more popular JS testing software, which could be a technical debt win in the long run.

Vitest doesn't appear to have much market share. It looks like as of 2022 it was rated 11th most popular, if this is accurate.

Jest of course is the # 1 most popular outside of the mediawiki ecosystem.

I would argue that there are some good advantages to preferring "popular" software such as Jest:

  • ease of onboarding (the software engineer might already know it)
  • more frequent library patches
  • doesn't become abandonware as quickly

Whatever is decided here, I just wanted to point this out. QUnit has low market share and so does Vitest. Jest might be an opportunity for mediawiki to standardize around more popular JS testing software, which could be a technical debt win in the long run.

Popularity is often a good consideration when evaluating a framework, but for me the most important thing here is that Vitest is the recommended framework for Vue, which is what we're using. For Jest in particular, the Vue docs say:

However, we only recommend Jest if you have an existing Jest test suite that needs to be migrated over to a Vite-based project, as Vitest offers a more seamless integration and better performance.

Volker_E renamed this task from Consider migrating from Jest to Vitest to build: Migrate from Jest to Vitest test-runner.Dec 2 2025, 11:05 PM
Volker_E updated the task description. (Show Details)
Volker_E updated the task description. (Show Details)
Volker_E added a subscriber: Nemoralis.
Volker_E removed a subscriber: Nemoralis.

Thanks for linking those stats in your recent edit to the original post. 3% Vitest vs 73% Jest (ranking/usage) is interesting.

image.png (156×1 px, 123 KB)