我在运行单元测试时收到错误“createSpyObj 需要非空数组”,该测试之前已完美执行

Aki*_*ake 5 unit-testing jasmine angularjs karma-jasmine

我正在开发 Angular 前端单元测试来更新声纳报告,

Chrome Headless 93.0.4577.63 (Windows 10) ERROR
  An error was thrown in afterAll
  createSpyObj requires a non-empty array or object of method names to create spies for thrown
Chrome Headless 93.0.4577.63 (Windows 10): Executed 994 of 1041 (skipped 20) ERROR (0 secs / 11.047 secs)
Chrome Headless 93.0.4577.63 (Windows 10) ERROR
  An error was thrown in afterAll
Chrome Headless 93.0.4577.63 (Windows 10): Executed 994 of 1041 (skipped 20) ERROR (16.566 secs / 11.047 secs)
Run Code Online (Sandbox Code Playgroud)

这是我收到的错误日志。之前所有测试都运行没有任何问题。在不同的组件中添加一些新测试后,突然出现此错误。然后我也删除了新的测试和新的组件。但我仍然收到此错误。但测试在自动打开的 Chrome 无头浏览器上执行时没有任何错误。为什么我会收到此错误

Ali*_*F50 4

查看代码库jasmine.createSpyObj并确保数组不为空。

// Make sure you don't see empty arrays like so when using jasmine.createSpyObj
// The array is supposed to be an array of strings of public methods
// you want to mock.

jasmine.createSpyObj([]);
jasmine.createSpyObj('SomeName', []);
Run Code Online (Sandbox Code Playgroud)