How to cover React jsx files in Istanbul?

后端 未结 4 1609
渐次进展
渐次进展 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条回答
  •  余生分开走
    2021-02-13 03:41

    In case someone else is having the same problem and solutions above don't work, I found that adding a simple "-e .jsx" tag worked:

    "scripts": {
       "start": "meteor run",
       "test": "NODE_ENV=test mocha --recursive --compilers js:babel-register --require tests/index.js ./tests/**/*.test.js",
       "coverage": "NODE_ENV=test nyc -all -e .jsx npm test"
    }
    

    This solution was found at: http://www.2devs1stack.com/react/tape/testing/nyc/coverage/2016/03/05/simple-code-coverage-with-nyc.html

提交回复
热议问题