From 462abf7027995b3deed6991ccbf7f196cae55ae5 Mon Sep 17 00:00:00 2001 From: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com> Date: Mon, 3 Nov 2025 19:47:01 +0100 Subject: [PATCH] [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? --- .github/CONTRIBUTING.md | 16 +- .gitignore | 3 + CHANGELOG.md | 1 + eslint.config.mjs | 16 +- js/app.js | 8 +- js/electron.js | 12 +- js/loader.js | 2 +- js/logger.js | 8 +- js/module_functions.js | 4 +- js/utils.js | 8 +- package-lock.json | 4965 ++++++----------- package.json | 22 +- tests/e2e/helpers/global-setup.js | 47 +- tests/e2e/ipWhitelist_spec.js | 6 +- tests/e2e/port_spec.js | 6 +- tests/e2e/serveronly_spec.js | 6 +- tests/e2e/template_spec.js | 3 +- tests/e2e/translations_spec.js | 10 +- tests/electron/helpers/global-setup.js | 46 +- tests/mocks/calendar_duplicates_1.ics | 87 + tests/mocks/calendar_duplicates_2.ics | 87 + tests/unit/classes/translator_spec.js | 2 +- .../updatenotification_spec.js.snap | 180 +- tests/unit/functions/server_functions_spec.js | 22 +- .../unit/functions/updatenotification_spec.js | 241 +- .../calendar/calendar_fetcher_utils_spec.js | 1 - tests/unit/modules/default/utils_spec.js | 2 +- tests/utils/test_sequencer.js | 30 - tests/utils/vitest-setup.js | 21 + vitest.config.mjs | 70 + 30 files changed, 2370 insertions(+), 3562 deletions(-) create mode 100644 tests/mocks/calendar_duplicates_1.ics create mode 100644 tests/mocks/calendar_duplicates_2.ics delete mode 100644 tests/utils/test_sequencer.js create mode 100644 tests/utils/vitest-setup.js create mode 100644 vitest.config.mjs diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 37d01ccc..2f22cbf2 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -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