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

  • 相关阅读:
    数据库知识总结
    servlet总结
    创建Dynamic Web Project工程
    Python--(爬虫与数据库的连接)
    Mongodb数据库操作
    Python Web(Django)连接SQL SERVER
    Python操作MySql
    Python(Django)项目与Apache的管理交互
    Python Django连接(听明白了是连接不是创建!)Mysql已存在的数据库
    Python selenium自动化网页抓取器
  • 原文地址:https://www.cnblogs.com/wxiaona/p/7526621.html
Copyright © 2011-2022 走看看