[tests] migrate from jest to vitest (#3940)

This is a big change, but I think it's a good move, as `vitest` is much
more modern than `jest`.

I'm excited about the UI watch feature (run `npm run test:ui`), for
example - it's really helpful and saves time when debugging tests. I had
to adjust a few tests because they had time related issues, but
basically we are now testing the same things - even a bit better and
less flaky (I hope).

What do you think?
This commit is contained in:
Kristjan ESPERANTO
2025-11-03 19:47:01 +01:00
committed by GitHub
parent b542f33a0a
commit 462abf7027
30 changed files with 2370 additions and 3562 deletions

View File

@@ -30,9 +30,19 @@ To run markdownlint, use `node --run lint:markdown`.
## Testing
We use [Jest](https://jestjs.io) for JavaScript testing.
We use [Vitest](https://vitest.dev) for JavaScript testing.
To run all tests, use `node --run test`.
The specific test commands are defined in `package.json`.
So you can also run the specific tests with other commands, e.g. `node --run test:unit` or `npx jest tests/e2e/env_spec.js`.
The `package.json` scripts expose finer-grained test commands:
- `test:unit` run unit tests only
- `test:e2e` execute browser-driven end-to-end tests
- `test:electron` launch the Electron-based regression suite
- `test:coverage` collect coverage while running every suite
- `test:watch` keep Vitest in watch mode for fast local feedback
- `test:ui` open the Vitest UI dashboard (needs OS file-watch support enabled)
- `test:calendar` run the legacy calendar debug helper
- `test:css`, `test:markdown`, `test:prettier`, `test:spelling`, `test:js` lint-only scripts that enforce formatting, spelling, markdown style, and ESLint.
You can invoke any script with `node --run <script>` (or `npm run <script>`). Individual files can still be targeted directly, e.g. `npx vitest run tests/e2e/env_spec.js`.