Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Compatibility with vitest? #1142

Unanswered
redbar0n asked this question in Q&A
Sep 27, 2022 · 3 comments · 9 replies
Discussion options

This Project is tested to work with Jest, but it should work with other test runners as well.

https://testing-library.com/docs/react-native-testing-library/intro/

Just wondering if someone has had it working with Vitest?

You must be logged in to vote

Replies: 3 comments 9 replies

Comment options

Hey, why not. Would you like to contribute example setup? :)

You must be logged in to vote
1 reply
Comment options

We try no to added any code that would force running on Jest, so there are high changes that RNTL will work with it out-of-the-box or with minor tweaks. However this is something we didn't try yet.

Comment options

I've been working with vitest-react-native, react-native(web as well) and testing-library for month or longer. There are millions of limitations, but together we can manage any issues

You must be logged in to vote
6 replies
Comment options

@YuriiLutsykSPRO can you elaborate more on your setup, whether it works faster (people frequently mention vitest as faster than Jest), the limitations. I am open to adding support for Vitest in RNTL if that would be a feasible option for testing.

Comment options

My setup is pretty simple now, i use the same setup as the https://github.com/sheremet-va/vitest-react-native library recomends, First and most important limitations is we can't mock libraries related to react native (as unistyles) in test/setupFiles, i didn't fix it. vitest-react-native isn't very reliable. Currently i'm working on fix for testing-library-react-native or react, because i can't use the functions as getByTestId and getByText with vitest

Comment options

I don't have a lot of tests to test properly the speed, but looks like vitest is faster than jest, but it' only my first assumption

Comment options

I have been very impressed with vitest and so I am very interested in trying to use vitest with react-native-testing-library. I am just getting started by doing web searches to see what experience others have had attempting this integration. Your optimism is inspiring, @YuriiLutsykSPRO !

I found this issue regarding ESM/CJS incompatibilities: sheremet-va/vitest-react-native#15

I am very early in my attempt, just researching, haven't even installed anything yet, but if CJS/ESM issues are likely to come up I'd love to hear any tips and tricks. This is something that seems to be solved in the jest+react-native-testing-libary world using package.json configuration

{ ...
 "jest": {
 ...
 "transformIgnorePatterns": [ ... ]
 }
}

Is there an equivalent needed in the vitest+react-native-testing-library situation?

Comment options

Maybe https://VxRN.dev would help: Using Vite instead of Metro for RN. Maybe @natew has some experience with testing with this setup.

Comment options

Have been trying to use React-Native-Testing-Library + React-Native + Expo + Vitest, and it's an endless pit of issues. Probably will take a week to tackle all the dependency issues, it's a bit of a nightmare. Like playing wack-a-mole.

You must be logged in to vote
2 replies
Comment options

What kind of issues are you facing?

Comment options

@natew tested compat with vxrn.dev or onestack.dev which is based on it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /