[PR #5754] [MERGED] chore(web): migrate to vitest #10962

Closed
opened 2026-02-05 14:31:06 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/immich-app/immich/pull/5754
Author: @jorge-dev
Created: 12/16/2023
Status: Merged
Merged: 1/1/2024
Merged by: @jrasm91

Base: mainHead: fix/web-dev-server-and-tests


📝 Commits (9)

  • 4e39559 Updated vite and ts config file with vtest options and a new alias to fix the dev command error
  • 27207be Updated package script and update the packages
  • 303ec16 Added new setup file needed in vitest in order to be able to use the jest-dom matchers in tests
  • 2879e96 Updated deprecated utilities when using faker
  • aaff5e9 Updated test files and mocks to use vitest instead of jest
  • e234e11 Enabled web test check in GitHub actions
  • 3dcdc44 remove babel dependencies as they are no longer needed with vitest
  • 0ea0578 move the jest config files to a folder in case we need to go back to jest
  • c465bdd chore: remove old files

📊 Changes

18 files changed (+6128 additions, -9981 deletions)

View changed files

📝 .github/workflows/test.yml (+3 -3)
web/babel.config.cjs (+0 -3)
web/jest.config.mjs (+0 -202)
📝 web/package-lock.json (+6027 -9716)
📝 web/package.json (+7 -11)
📝 web/src/lib/__mocks__/jsdom-url.mock.ts (+1 -1)
📝 web/src/lib/components/album-page/__tests__/album-card.spec.ts (+26 -11)
📝 web/src/lib/components/shared-components/notification/__tests__/notification-card.spec.ts (+1 -2)
📝 web/src/lib/components/shared-components/notification/__tests__/notification-list.spec.ts (+5 -5)
📝 web/src/lib/utils/asset-utils.spec.ts (+0 -1)
📝 web/src/lib/utils/executor-queue.spec.ts (+8 -10)
📝 web/src/lib/utils/time-to-seconds.spec.ts (+0 -1)
📝 web/src/routes/(user)/albums/__tests__/albums.bloc.spec.ts (+27 -7)
📝 web/src/test-data/factories/album-factory.ts (+2 -2)
📝 web/src/test-data/factories/user-factory.ts (+4 -4)
web/src/test-data/setup.ts (+1 -0)
📝 web/tsconfig.json (+2 -1)
📝 web/vite.config.js (+14 -1)

📄 Description

This change fixes an error while trying to run the npm run dev command and serve the application.
This was due to a missing alias in the vite config file.

The change is to re-enable the existing unit tests that were failing after the update to Svelte 4.
Most of the tests were failing due to Jest trying to import packages using require instead of import since it was running in CSJ mode instead of ESM mode that Svelte 4 requires.
I spent 2 days trying to configure jest to fix this issue but nothing worked.

That was the main reason to try vitest for this project.
Vitest works with almost no extra configuration and it was built using ESM so all the tests were able to be fixed with very minor modifications since vitest's api is almost fully compatible with Jest API (with some exceptions)

These changes only affect the testing environment
image


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/immich-app/immich/pull/5754 **Author:** [@jorge-dev](https://github.com/jorge-dev) **Created:** 12/16/2023 **Status:** ✅ Merged **Merged:** 1/1/2024 **Merged by:** [@jrasm91](https://github.com/jrasm91) **Base:** `main` ← **Head:** `fix/web-dev-server-and-tests` --- ### 📝 Commits (9) - [`4e39559`](https://github.com/immich-app/immich/commit/4e39559fd2efa095b7b0fc90a33780821b9baa1b) Updated vite and ts config file with vtest options and a new alias to fix the dev command error - [`27207be`](https://github.com/immich-app/immich/commit/27207be8cf3c164b00c2cc41dbe62733b025dbeb) Updated package script and update the packages - [`303ec16`](https://github.com/immich-app/immich/commit/303ec169aa9f4e79434433e80a818d6c69dfc677) Added new setup file needed in vitest in order to be able to use the jest-dom matchers in tests - [`2879e96`](https://github.com/immich-app/immich/commit/2879e964520796f573eccba2e94d45bfd5851c3f) Updated deprecated utilities when using faker - [`aaff5e9`](https://github.com/immich-app/immich/commit/aaff5e934b5b40c100912aaac63c5f5fc24ead9b) Updated test files and mocks to use vitest instead of jest - [`e234e11`](https://github.com/immich-app/immich/commit/e234e11c207fb53d18ef9c31f7ebe1ecf3248ed2) Enabled web test check in GitHub actions - [`3dcdc44`](https://github.com/immich-app/immich/commit/3dcdc44a7660488c1ba24fdeb6ede0a8be1224be) remove babel dependencies as they are no longer needed with vitest - [`0ea0578`](https://github.com/immich-app/immich/commit/0ea057809fe8524c8e77ba341e92c5d14e3aa272) move the jest config files to a folder in case we need to go back to jest - [`c465bdd`](https://github.com/immich-app/immich/commit/c465bdd068ec8912a17baff0353e6a964eb56733) chore: remove old files ### 📊 Changes **18 files changed** (+6128 additions, -9981 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/test.yml` (+3 -3) ➖ `web/babel.config.cjs` (+0 -3) ➖ `web/jest.config.mjs` (+0 -202) 📝 `web/package-lock.json` (+6027 -9716) 📝 `web/package.json` (+7 -11) 📝 `web/src/lib/__mocks__/jsdom-url.mock.ts` (+1 -1) 📝 `web/src/lib/components/album-page/__tests__/album-card.spec.ts` (+26 -11) 📝 `web/src/lib/components/shared-components/notification/__tests__/notification-card.spec.ts` (+1 -2) 📝 `web/src/lib/components/shared-components/notification/__tests__/notification-list.spec.ts` (+5 -5) 📝 `web/src/lib/utils/asset-utils.spec.ts` (+0 -1) 📝 `web/src/lib/utils/executor-queue.spec.ts` (+8 -10) 📝 `web/src/lib/utils/time-to-seconds.spec.ts` (+0 -1) 📝 `web/src/routes/(user)/albums/__tests__/albums.bloc.spec.ts` (+27 -7) 📝 `web/src/test-data/factories/album-factory.ts` (+2 -2) 📝 `web/src/test-data/factories/user-factory.ts` (+4 -4) ➕ `web/src/test-data/setup.ts` (+1 -0) 📝 `web/tsconfig.json` (+2 -1) 📝 `web/vite.config.js` (+14 -1) </details> ### 📄 Description This change fixes an error while trying to run the `npm run dev` command and serve the application. This was due to a missing alias in the vite config file. The change is to re-enable the existing unit tests that were failing after the update to Svelte 4. Most of the tests were failing due to Jest trying to import packages using require instead of import since it was running in CSJ mode instead of ESM mode that Svelte 4 requires. I spent 2 days trying to configure jest to fix this issue but nothing worked. That was the main reason to try vitest for this project. Vitest works with almost no extra configuration and it was built using ESM so all the tests were able to be fixed with very minor modifications since vitest's api is almost fully compatible with Jest API (with some exceptions) These changes only affect the testing environment <img width="1093" alt="image" src="https://github.com/immich-app/immich/assets/20519640/17fec077-3dbc-49d1-b511-60734c431155"> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 14:31:06 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#10962