javascript - Typescript Jasmine toHaveBeenCalledTimes() is not a function -


i have test in typescript application:

    it("should send current state when new subscriber added (watching on 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);                 });             }         ); 

when compile js, there no errors. when run it, have following error:

typeerror: expect(...).tohavebeencalledtimes not function

how test, how many times function of spyobj called? in advance.

take here , , go section of "other tracking properties"

you can try using .calls.count() property.

so test becomes: expect(subscriber.processnotifyaction.calls.count()).toequal(2)

side note - of course assuming version of jasmine supports this, should unless have old version of jasmine.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -