Code coverage with Mocha

后端 未结 3 1679
故里飘歌
故里飘歌 2020-12-07 06:55

I am using Mocha for testing my NodeJS application. I am not able to figure out how to use its code coverage feature. I tried googling it but did not find any proper tutoria

3条回答
  •  被撕碎了的回忆
    2020-12-07 07:21

    You need an additional library for code coverage, and you are going to be blown away by how powerful and easy istanbul is. Try the following, after you get your mocha tests to pass:

    npm install nyc
    

    Now, simply place the command nyc in front of your existing test command, for example:

    {
      "scripts": {
        "test": "nyc mocha"
      }
    }
    

提交回复
热议问题