Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(web): migrate to vitest #5754

Merged
merged 9 commits into from
Jan 1, 2024

Conversation

jorge-dev
Copy link
Contributor

@jorge-dev jorge-dev commented Dec 16, 2023

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

@jorge-dev jorge-dev force-pushed the fix/web-dev-server-and-tests branch 2 times, most recently from 1d14196 to 4946666 Compare December 16, 2023 22:44
@jorge-dev jorge-dev changed the title Fix(web): Fix web dev serve command and update test to use vitest Fix(web): Fix web dev serve command and enabled web unit tests again Dec 16, 2023
@jorge-dev jorge-dev marked this pull request as ready for review December 17, 2023 22:12
@jrasm91 jrasm91 changed the title Fix(web): Fix web dev serve command and enabled web unit tests again chore(web): migrate to vitest Jan 1, 2024
@jrasm91 jrasm91 enabled auto-merge (squash) January 1, 2024 16:36
Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for re-enabling the tests again.

@jrasm91 jrasm91 merged commit 5f6d09d into immich-app:main Jan 1, 2024
20 checks passed
@jorge-dev jorge-dev deleted the fix/web-dev-server-and-tests branch January 1, 2024 22:43
martabal pushed a commit that referenced this pull request Jan 9, 2024
* Updated vite and ts config file with vtest options and a new alias to fix the dev command error

* Updated package script and update the packages
 -- this removes jest dependencies

* Added new setup file needed in vitest in order to be able to use the jest-dom matchers in tests

* Updated deprecated utilities when using faker

* Updated test files and mocks to use vitest instead of jest

* Enabled web test check in GitHub actions

* remove babel dependencies as they are no longer needed with vitest

* move the jest config files to a folder in case we need to go back to jest

* chore: remove old files

---------

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants