Personal Blog

Angular converting circular structure JSON

Mon 17 May 2021

Had this wierd error in the latest angular version 12.0.0 that I haven't seen before while running unit tests.

TypeError: Converting circular structure to JSON

It turns out I haven't provided all the providers to the TestBed. Make sure all of the providers are there. In my case there was a typo

{ provide: ProviderClass, useValue: ProviderClassStub }
// Should be
{ provide: ProviderClass, useClass: ProviderClassStub }