[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

@@ -52,17 +52,19 @@
"start:windows:dev": "node --run start:windows -- dev",
"start:x11": "DISPLAY=\"${DISPLAY:=:0}\" ./node_modules/.bin/electron js/electron.js",
"start:x11:dev": "node --run start:x11 -- dev",
"test": "NODE_ENV=test jest -i --forceExit",
"test": "vitest run",
"test:calendar": "node ./modules/default/calendar/debug.js",
"test:coverage": "NODE_ENV=test jest --coverage -i --verbose false --forceExit",
"test:coverage": "vitest run --coverage",
"test:css": "stylelint 'css/main.css' 'css/roboto.css' 'css/font-awesome.css' 'modules/default/**/*.css'",
"test:e2e": "NODE_ENV=test jest --selectProjects e2e -i --forceExit",
"test:electron": "NODE_ENV=test jest --selectProjects electron -i --forceExit",
"test:e2e": "vitest run tests/e2e",
"test:electron": "vitest run tests/electron",
"test:js": "eslint",
"test:markdown": "markdownlint-cli2 .",
"test:prettier": "prettier . --check",
"test:spelling": "cspell . --gitignore",
"test:unit": "NODE_ENV=test jest --selectProjects unit"
"test:ui": "vitest --ui",
"test:unit": "vitest run tests/unit",
"test:watch": "vitest"
},
"lint-staged": {
"*": "prettier --ignore-unknown --write",
@@ -98,15 +100,16 @@
},
"devDependencies": {
"@stylistic/eslint-plugin": "^5.5.0",
"@vitest/coverage-v8": "^4.0.6",
"@vitest/ui": "^4.0.6",
"cspell": "^9.2.2",
"eslint-plugin-import-x": "^4.16.1",
"eslint-plugin-jest": "^29.0.1",
"eslint-plugin-jsdoc": "^61.1.11",
"eslint-plugin-package-json": "^0.59.1",
"eslint-plugin-vitest": "^0.5.4",
"express-basic-auth": "^1.2.1",
"husky": "^9.1.7",
"jest": "^30.2.0",
"jsdom": "27.0.0",
"jsdom": "^27.1.0",
"lint-staged": "^16.2.6",
"markdownlint-cli2": "^0.18.1",
"playwright": "^1.56.1",
@@ -114,7 +117,8 @@
"prettier-plugin-jinja-template": "^2.1.0",
"stylelint": "^16.25.0",
"stylelint-config-standard": "^39.0.1",
"stylelint-prettier": "^5.0.3"
"stylelint-prettier": "^5.0.3",
"vitest": "^4.0.6"
},
"optionalDependencies": {
"electron": "^38.3.0"