Nodejs,Istanbul 单元测试覆盖率,浏览器版本报告没有出现百分比,

本文档详细记录了在Node.js中遇到的handlebars@4.7.6版本导致的单元测试覆盖率报告百分比缺失的问题。通过降级到handlebars@4.5.3并执行相应命令,成功解决了此问题。文中包含问题复现、解决步骤及不同版本handlebars的终端和浏览器报告截图。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

单元测试覆盖率,浏览器版本报告没有出现百分比;Handlebars: Access has been denied to resolve the property "statements" be...

Handlebars: Access has been denied to resolve the property "statements" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "branches" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "functions" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "lines" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details

题目中的问题从Hadnlebars官方文档得到了答案,文档

下面是问题复现和解决步骤;


handlebars@4.7.6 error 复现:

使用 handlebars@4.7.6 的时候

  • 运行命令:
$ npm run coverage 
  • 问题截图:
    终端截图

  • 浏览器报告截图:
    覆盖率界面报告

  • handlebars@4.7.6 版本信息截图:
    handlebars版本信息


使用 handlebars@4.5.3 的时候:

  • 命令
    首先 命令 or 手动删除 handlebars
    然后运行👇命令
$ npm install handlebars@4.5.3

+ handlebars@4.5.3
added 3 packages from 1 contributor, updated 1 package and audited 514 packages in 6s

30 packages are looking for funding
  run `npm fund` for details

found 2 low severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details

开始单元测试命令:

$ npm run coverage
  • 终端截图:
    终端截图-4.5.3版本情况

  • 浏览器报告截图:
    浏览器截图-4.5.3版本情况

  • handlebars@4.5.3 版本信息截图:

4.5.3版本信息.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值