I want to test ngLogger function with jasmine marble but a got error
Expected $.length = 2 to equal 1.
Expected $.length = 2 to equal 1.
Expected $[0].frame = 0 to equal 10.
Expected $[0].notification.value to be a kind of Observable, but was Object({ type: 'TECHNICAL', level: 'ERROR', msg: 'test' }).
Expected $[1] = Object({ frame: 0, notification: Notification({ kind: 'C', value: undefined, error: undefined, hasValue: false }) }) to equal undefined.
Test:
export namespace GlobalUtils {
export function ngLogger(error: string):
Observable<Log> {
return of({ type: LogEnum.TECHNICAL,
level: LevelEnum.ERROR,
msg: error } as Log
);
}
}
import { GlobalUtils } from './global.utils';
it('ngLogger should be return an Observable', () => {
const expected = of({
type: LogEnum.TECHNICAL,
level: LevelEnum.ERROR,
msg: 'test'
});
const expected$ = hot('-a', { a: expected });
const result$ = GlobalUtils.ngLogger('test');
expect(result$).toBeObservable(expected$);
});
const expected$ = hot('a', { a: expected });
don't do any difference. const expected$ = hot('a|', { a: expected });
give the error :
Expected $[0].notification.value to be a kind of Observable, but was Object({ type: 'TECHNICAL', level: 'ERROR', msg: 'test' }).
Expected $[1].frame = 0 to equal 10
then I changed
const expected = of({
type: LogEnum.TECHNICAL,
level: LevelEnum.ERROR,
msg: 'test'
});` to `const expected = of({
type: LogEnum.TECHNICAL,
level: LevelEnum.ERROR,
msg: 'test'
});
I get the error Expected $[1].frame = 0 to equal 10.
what does it means ?
const expected$ = hot('a', { a: expected });
or evenconst expected$ = hot('a|', { a: expected });
? – Illusiveconst expected$ = hot('a', { a: expected });
don't do any difference. – Changchangaris(a|)
as this is how you describe simultaneous emit and end observable which is done when usingof
second issue is that you have your expected defined as observable and it should be only the data inside – Illusive