typescriptjasminekarma-jasmine

jasmine.clock().autoTick() - autoTick is not a function


Here's the repo. There is a test where I want to use jasmine.clock().autoTick():

   fit("show verification field", async () => {
      jasmine.clock().install();
      jasmine.clock().mockDate();
      jasmine.clock().autoTick();
      ...
   }

But when the test runs I get the error:

TypeError: jasmine.clock(...).autoTick is not a function

I think the repo uses the latest jasmine packages:

"jasmine-core": "^5.11.0",
"karma-jasmine": "~5.1.0",

jasmine-core 5.11.0 does support autoTick(). Why the error?


Solution

  • ok, turns out karma-jasmine is actually running jasmine-core v.4.6.x. Overriding this dependency in package.json does the trick:

      ...
      "overrides": {
        "karma-jasmine": {
          "jasmine-core": "^5.0.0"
        }
      }
    }
    

    And don't forget to clear node_modules folder and reinstall all the packages.