-
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
Code coverage reporting with other unit tests #470
Comments
Not sure how we can add coverage by Detox since the tests don't run your JS code in node. Instead, it commands the device and the app to do stuff, and then asserts that something has changed in the native view hierarchy on the device/simulator. I believe this will never be possible. |
Can I just chip in here as a developer evaluating Detox for a company project?
|
1 - I strongly agree Do you have an idea of how to approach this ? I'd be happy to an elaborate idea to understand the feasibility of this kind of feature. |
@rotemmiz Yes, I think I can help formulate an approach. Using gotwarlost/istanbul#16 (comment) as a template:
The rest pretty much applies as-is - The Detox Node client will be able to output coverage files and pretty reports the same way e.g. Jest does it, using libraries in the
|
@rotemmiz Would you like to reopen this issue? I'd be happy to start tinkering with the code with an eye to eventually contributing a PR. |
Sure, do it! It sounds amazing if it's doable! |
I'm looking for a way to |
Why not bundle it with the packager ? |
We need to specifically read this variable at That would indeed require us to inject some JS code through the packager. Is this possible to automate in Detox? |
Not currently, only with repackager |
Hmm. Alternatively, maybe I can put together a standalone, pure JS solution for collecting coverage from a React Native app, and we can tackle Detox integration as a second step? |
OK, based on my realisation above that most of what's needed here isn't actually Detox-specific (or even React Native-specific), I've started a project I'm tentatively calling bosphorus, which provides tools for serialising IstanbulJS coverage data from running apps over a socket connection. The architecture is, unsurprisingly, inspired by Detox itself 😄. Here's an example of reporting coverage from a basic Expo app running in the Simulator. No Detox in there yet but I'll be looking into that next - help welcome! Now, what's needed on the Detox side for a seamless developer experience? Here's what I think is essential:
And then for bonus points:
|
Wow, this is amazing! Keeping an eye on that project. |
Might interest you guys as a potential solution but I'm getting coverage in-process via my TL;DR Here's a gif of the core features test suite running, as you can see it's rapid: And here's a gist of the test suite shown above - gives you an idea of what it's doing and what you have access to - no limits e.g. here's an output coverage report of our |
Ooh, nice @Salakar! Is that conceptually/technically similar to how the "debug JS remotely" feature works? This is pretty awesome. |
@motiz88 yep pretty much that except it automatically enables that for you and takes over as the debugger instead of chrome - even across reloads/relaunches There's no visible lag or performance hit in doing so that I've noticed either - a quick FPS test I ran the other day maintained around ~55 FPS - so it is lag free and just as performant as the chrome debugger if not more. Am hoping to have a version published by the end of the weekend. |
@motiz88 I have just pushed up my playground app project with this all in if you'd like to take a look: https://github.com/invertase/react-native-firebase/tree/bridge-detox/tests-new Includes nyc/Istanbul coverage all configured. Bridge code is is bridge dir, I just need to move it out to own repo, document it and publish to npm, but sleep first 😩 (Android only, I still need to configure the iOS project) EDIT: now with automatic source mapping of stack traces: |
I'll say it again @Salakar - that is awesome stuff! I will definitely be tinkering with On the Bosphorus front, still early days (day 2 to be exact!) but I have gotten it to work with Jest + Detox in what I think is a pretty viable way - no changes to Detox required: https://github.com/motiz88/bosphorus/tree/master/examples/expo-app#readme I'll continue working on the reliability & ease of setup of this solution, and give it a go with Android soon. An npm release will follow when I'm reasonably confident the thing will really work on machines other than mine 😅 |
@motiz88 cool will keep an eye on your project as well. This might be a useful thing for you; nyc/instanbul can wrap directly around detox cli commands, so as long as you can populate Links for reference: |
Well, I just published an alpha to NPM 🙈 https://github.com/invertase/jet - need to document it fully but it's working fully on both platforms. |
Wondering if there was ever a solution to getting some metrics associated with detox and code coverage? |
@noomorph Isn't this something similar to what you did? |
Closing this issue. This should come from the community—we don't have the capacity to create or support a full blown solution. |
Hi,
I want to view the code coverage of my tests with my regular unit tests. I already use jest code coverage reporting in my unit tests and iI would like to merge add the coverage by detox.
The text was updated successfully, but these errors were encountered: