我想用茉莉花大理石测试 ngLogger 函数,但出现错误
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.
测试:
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 });
不要做任何区别。const expected$ = hot('a|', { a: expected });
给出错误:
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
然后我改变了
const expected = of({
type: LogEnum.TECHNICAL,
level: LevelEnum.ERROR,
msg: 'test'
});` to `const expected = of({
type: LogEnum.TECHNICAL,
level: LevelEnum.ERROR,
msg: 'test'
});
我得到错误Expected $[1].frame = 0 to equal 10.
是什么意思?