ではありません。活字体ジャスミンtoHaveBeenCalledTimesは()私はtypescriptですアプリケーションでテストを持っている機能
it("Should send current state when new subscriber is added (watching over file)",
() => {
runs(() => {
flag = false;
subscriber = createSpyObj<IPathWatchSubscriber>("PathWatchSubscriberMock", ["processNotifyAction"]);
subscriber2 = createSpyObj<IPathWatchSubscriber>("PathWatchSubscriberMock", ["processNotifyAction"]);
pathWatch.subscribe(subscriber);
pathWatch.watch(filePath);
pathWatch.subscribe(subscriber2);
w(() => { flag = true; });
});
waitsFor((): boolean => {
return flag;
}, "failure", chokidarOperationDelay);
runs(() => {
expect(subscriber.processNotifyAction).toHaveBeenCalledWith(expectedNotifyAction);
expect(subscriber.processNotifyAction).toHaveBeenCalledTimes(2);
expect(subscriber2.processNotifyAction).toHaveBeenCalledWith(expectedNotifyAction);
});
}
);
私はjsファイルにコンパイルすると、エラーがありません。 SpyObjの
TypeError: expect(...).toHaveBeenCalledTimes is not a function
どのようにテストするために、何回関数が呼び出されました:私はそれを実行したときしかし、私はエラーを次がありますか? ありがとうございます。
ありがとう、あなたの回避策は私のために働く。もう一つ、私はCreateSpyObjectからSpyOnに切り替え、 ".calls.count()"を使用しました。 –