-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Setting up detox with Vitest as the test runner #4185
Comments
Oh, this ain't a trivial task, I'd say. 😬 You'd need to learn thoroughly how Detox + Jest integration works, and create a similar one for Vitest. I see that you did not create a custom test environment: https://vitest.dev/config/#environment So you should extend Vitest's Node environment where you'd call detox.init()/detox.installWorker()/detox.uninstallWorker()/detox.cleanup(). P. S. If I were assigned to create such an implementation, I'd estimate at least a full working week for a quick'n'dirty POC. A good implementation would likely involve some rewrites in Detox's source code, and that would take a month or more. Make sure you have enough time dedicated if you're serious about writing a third-party integration. |
@noomorph yeah i have yet to create a custom environment - i had a feeling that was the route i would need to go but i felt like i needed to check and see if there were other instances somewhere else that i had missed before opening possibly a can of worms implementing this :P Will detox be closely tied to jest for the forseable future? Are there plans to make integration with third party runners easier? |
Sorry, I missed your mention and by accident found it now. Yes, it is rather correct that Detox will be focusing specifically on Jest in the foreseeable future, and this is not accidental — its source code is still somewhat messed up due to ad-hoc simultaneous integrations with two test runners back in the day. Healing it takes time. It might sound like a paradox but the stronger we are integrating Detox with Jest, the cleaner, smaller and simpler its core becomes. At some point (hopefully, Detox 22) we'll totally split the automation interface (device and app interactions) from test runner layer, and the authors of test integrations will be given absolute freedom of how to integrate Detox with a test runner of their choice — i.e. there won't be any specific lifecycle to adhere to, just API with devices and their apps and elements. That way the authors won't have to look back at our docs and various quirks, although it has to be admitted that all these improvements won't reduce the amount of glue code — it should just become more straightforward and obvious to grasp. I'd love to play with Vitest in spare time and see what can be done, but I know that the community's demand is rather to improve onboarding and troubleshooting experience (especially on Android) and maintain API parity between the platforms as it grows. So, a bird in the hand is worth two in the bush, speaking of test runners. For example, I am not satisfied with artifacts subsystem and timeout errors currently in Jest, and it is preferable to make one runner work flawlessly than to produce weak integrations with many. The mentioned improvements will bring more insights to "what makes Detox+Test runner integration really good", and that will benefit the community later, I believe. |
Just in case if you have a spare couple of minutes to share why Vitest integration would be a better fit for your needs, I'd be happy to read. Maybe I can learn something for the future or the present. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions! For more information on bots in this repository, read this discussion. |
@noomorph Vitest really has significant better performance. Which is critical for keeping the testing experience satisfying. As a TDD dev guy, I really enjoy vitest for giving me fast feedback. I use it for unit test mainly. I am ok with setting Detox with jest for e2e tests, yet this dual configuration adds complexity. |
We're also moving away from Jest towards Vitest in the rest of our stack, so we'd love to see the ability to use it here as well |
@amehmeto, @kyranjamie, thanks for bringing this to our attention. I have a couple of things to say:
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions! For more information on bots in this repository, read this discussion. |
Description
I've just recently set up Detox in our project, but we're looking strip jest from our code base completely and we're in the process of migrating to vitest instead.
The detox documentation states that there is support for third party test runners so i tried to set up detox with vitest
My vitest setup is fairly simple at the moment
and i've updated the
.detoxrc
configuration to use vitest as wellBuilding on iOS is fine, but when i try to run a test i get the following error
I havent found any other documentation online or examples of using a third party test runner, so im coming here to see if there is anyone that has done this with vitest/knows if this is possible? Or maybe its recommended to not use vitest?
Any help or insight would be appreciated!
NOTE: If i just use the default setup with jest as the test runner, everything runs smoothly
Your environment
Detox version: 20.11.2
React Native version: 0.72.1
Node version: 16
Device model:
OS:
Test-runner (select one): jest / other
The text was updated successfully, but these errors were encountered: