Skip to content

feat: replace jest with vitest #154

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

Merged
merged 8 commits into from
Apr 7, 2025
Merged

feat: replace jest with vitest #154

merged 8 commits into from
Apr 7, 2025

Conversation

SRWieZ
Copy link
Member

@SRWieZ SRWieZ commented Jan 13, 2025

Replacing Jest with Vitest 🎉

Works out of the box with ESM and has fewer dependencies. And, error messages are much more clear.

  • Updated tests to use vitest instead of. jest
  • Added a new mock implementation for the electron module using vitest and a new test file to verify the mocking of the electron module using vitest. (resources/js/electron-plugin/tests/mocking.test.ts)
  • Removed a bunch of jest configuration files and dependencies since vitest supports ESM out of the box.
  • Bumped dependencies of vite, electron-vite and some eslint and stylelint plugins

But ⚠️ :

  • Removed old Jest mocks and tests for clipboard, dialog, and window endpoints (endpoints/clipboard.test.ts, endpoints/dialog.test.ts, endpoints/window.test.ts).
  • Mocking Electron is unreliable in both Jest and Vitest. I managed to get some tests working, but others broke. I believe we need to shift to end-to-end tests using Selenium/Playwright and the kitchen-sink app. The remaining tests still verify the boot process of the API server.

@SRWieZ
Copy link
Member Author

SRWieZ commented Mar 1, 2025

This is the best I can do right now 😅

If you have any suggestion, feel free to edit this PR.

Updated my first comment.

@gwleuverink @PeteBishwhip @simonhamp

@SRWieZ SRWieZ marked this pull request as ready for review March 1, 2025 13:33
@PeteBishwhip PeteBishwhip self-requested a review March 3, 2025 10:27
@simonhamp
Copy link
Member

Should we get these conflicts resolved and merge this in too?

@SRWieZ
Copy link
Member Author

SRWieZ commented Apr 4, 2025

Yes, we should.

I now strongly believe this is not the right way to test electron features/api. They are still a bit useful in this state, but we should rely more on e2e in the future.

@SRWieZ
Copy link
Member Author

SRWieZ commented Apr 4, 2025

I can merge conflict later this afternoon.

SRWieZ added 2 commits April 4, 2025 17:41
# Conflicts:
#	resources/js/electron-plugin/tests/endpoints/dialog.test.ts
#	resources/js/package-lock.json
#	resources/js/package.json
#	resources/js/yarn.lock
@SRWieZ
Copy link
Member Author

SRWieZ commented Apr 4, 2025

Ready!

@simonhamp
Copy link
Member

I wonder why the plugin build is failing now here... maybe it's missing the GitHub token in that action?

@SRWieZ
Copy link
Member Author

SRWieZ commented Apr 4, 2025

Yeah, I saw, but it's unrelated to my code, the build works, It's committing on my branch that doesn't.

I think it's because this branch is still in my old fork of the project (srwiez/fork-nativephp-electron)

So, I suppose the workflow won't work on our contributors' branches.

Anyway, it seems like this workflow still needs some love.

@simonhamp
Copy link
Member

I suppose the workflow won't work on our contributors' branches.

Yep that's it

@simonhamp simonhamp merged commit 6a10202 into NativePHP:main Apr 7, 2025
28 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants