I'm trying to write a unit test and I'm getting this error.
TypeError: Cannot read property 'pipe' of undefined at Jasmine
const mockServiceObj = jasmine.createSpyObj < FormRegistrationService > (["registerForm", "pipe"]);
const getCurrentSystemPreference = jasmine.createSpyObj < CurrentSystemPreferencesService > ([
"getCurrentSystemPreference",
"pipe",
]);
function getServiceManagerLinks(): ServiceManagerSharedLinksComponent {
return new ServiceManagerSharedLinksComponent(null, mockServiceObj, getCurrentSystemPreference);
}


Probably the correct (or at least close to correct) unit tests approach for your situation.
You have
currentSystemPreferencesServiceconst and provide it toproviders. Now it's accessible in all tests cases. You also providegetPreferencesfield as callable method. Andof(true)means you return onObservablewhich is needed forpipe()in real code since you immediately call.pipe(...)after callinggetPreferences(SystemPreference.APITestValue)