更新时间:2023-11-20 21:20:58
JSTestDriver中的代码覆盖范围不喜欢let
和const
.它不会在包含它的任何文件上运行代码覆盖范围,并且不允许包含它的文件中的功能.
Code coverage in JSTestDriver does not like let
and const
. It will not run code coverage on any files that contain it and will not allow functions from a file that contains it.
对于我的特殊情况,我有一个使用const
的函数.我正在测试的函数中没有调用使用它的函数,因此从未进行过测试.这意味着测试通过了.但是,在同一个文件中足以使代码覆盖范围中断.
For my particular case I had a function that used const
. The function that used it was not called in the functions I was testing and thus was never tested at all. This meant the tests passed. However, being in the same file was enough to make code coverage break.
我的解决方案?将let
和const
都更改为var
.从语义上讲,这可能不是***的主意,但就我而言,这对我的代码或行为没有明显的影响.
My solution? Change both let
and const
to var
. Semantically it may not be the best idea but in my case it made no noticeable difference to my code or the behaviour.