How to cover React jsx files in Istanbul?

后端 未结 4 1610
渐次进展
渐次进展 2021-02-13 03:14

I\'m trying to integrate my existing test processes to now include React, but am struggling on the code coverage part. I\'ve been able to get my unit tests working fine by foll

4条回答
  •  萌比男神i
    2021-02-13 03:23

    Add a .istanbul.yml file to your app root and add .jsx to extensions "extension"...

    Here is what I did.

    // File .istanbul.yml
    instrumentation:
        root: .
        extensions: ['.js', '.jsx']
    

    To kickstart istanbul and mocha with jsx

    $ istanbul test _mocha -- test/**/* --recursive --compilers js:babel/register
    

    This will convert your .jsx files to .js and then istanbul will cover them.

    I hope this helps. It worked for me.

提交回复
热议问题