Home > front end >  I am getting an error "createSpyObj requires a non-empty array" with running unit tests, w
I am getting an error "createSpyObj requires a non-empty array" with running unit tests, w

Time:09-22

I am working on an Angular frontend unit test for updating the Sonar report,

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)

This is the error log I am getting. Previously all the tests ran without any problem. After a few new tests were added in a different component suddenly this error popped up. Then I removed the new tests and the new component also. But I am still getting this error. But the tests are executing without any error on the Chrome headless browser that automatically opens. Why am I getting this ERROR

CodePudding user response:

Look through the code base for jasmine.createSpyObj and ensure that the array is not empty.

// 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', []);
  • Related