'Angular Component is Undefined in Jasmine Test

Please help.

I think I defined test configs right.

But this throws Provider error for LayoutService.

This is my test code

This is the error



Solution 1:[1]

createSpyObj has the following description from the Jasmine documentation:

createSpyObj(baseName, methodNames, propertyNames)

The method takes as arguments the name of the Service to be mocked, and the second argument is an array of all the methods inside that class that needs to be mocked.

You should pass to your spy object the original service name and methods that are used by your code.

spyLayoutService = jasmine.createSpyObj('CsLayoutService', ['...'])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Oleksii Nuzhyn