zoukankan      html  css  js  c++  java
  • nodeJs should+mocha+istanbul 测试 遇到的坑

    、istanbul 和 mocha 结合进行nodejs测试的时候最后执行 istanbul cover _mocha test.sqrt.js的时候报错

    如图:

    用 ../node_modules/mocha/bin/_mocha 代替 _mocha

    即,执行的命令为 istanbul cover ../node_modules/mocha/bin/_mocha test.sqrt.js

    注意目录结构。

    以下为此目录结构,

    项目依赖:并且istanbul 为全局安装 npm install -g istanbul

    sqrt.js 代码

    test.sqrt.js 代码

    istanbul 会生成一个coverage文件夹,里面的html文件为测试报告

    并且能看到有哪些语句、分支等没覆盖

     2、instanbul + mocha + async/await 后出现的问题

    regeneratorRuntime is not defined

    解决问题:

    首先package.json中运行的语句:

    其次,由于async/await的使用需要安装插件。

    在.babel文件中加入

    3、async Unexpected token

    node 版本不对,原本是node6.1.4    升级版本到node8.0

    4、mocha debug 调试

    方法:http://www.cnblogs.com/wade-xu/p/4683431.html

    但是当安装node-inspector失败的时候,要检查node版本,必须是node6.9及一下版本。

    所以,当即想用debug又想用async/await  node版本冲突

    5、 No coverage information was collected, exit without writing coverage information

    使用 --compilers js:babel/register

    或者更新istanbul的版本

    npm install --save-dev istanbul@1.0.0-alpha.2

    npm install -g istanbul@1.0.0-alpha.2

    6、transformation error ; return original code

     

     解决方法:

     7、Warning: Could not find any test files matching pattern: js:babel/register

  • 相关阅读:
    MXNet.gluon——图像I/O
    ECCV2018 论文简析 Oral_1 持续更新
    hdu 3123 GCC
    hdu 2481 Toy
    hdu 3441 Rotation
    hdu 1812 Count the Tetris
    hdu 3923 Invoker
    hdu 1352 I Conduit!
    2013 ACM-ICPC长沙赛区全国邀请赛——Bottles Arrangement
    2013 ACM-ICPC长沙赛区全国邀请赛—Special equations
  • 原文地址:https://www.cnblogs.com/wxiaona/p/7526621.html
Copyright © 2011-2022 走看看