Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate code coverage report with jest and detox?

I'm using jest for unit tests and detox for some automation (using jest as test runner). Here's my setup in package.json

"jest": {
        "preset": "react-native",
        "collectCoverage": true,
        "coverageReporters": [
            "json",
            "html"
        ],
        "testPathIgnorePatterns": [
            "/node_modules/",
            "/.history/",
            "/e2e/"
        ]
    },
"detox": {
        "test-runner": "jest",
        "runner-config": "e2e/config.json",
        "configurations": ...
    }

I want to see the combined code coverage, how should I do it?

like image 594
mjabadilla Avatar asked Mar 08 '23 07:03

mjabadilla


1 Answers

I just got an answer from detox's development team that this might never be possible to do

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.

link- https://github.com/wix/detox/issues/470

UDPATE: Looks like https://github.com/wix/detox/issues/470 has been reopened and folks are actively working on making Detox test coverage possible! Never say never :D

like image 85
mjabadilla Avatar answered Mar 09 '23 21:03

mjabadilla