Jest Moment Is Not A Function, Unable to get Jest test to pass in Angular. However this mocked function is never called and fails Mock functions make it easy to test the links between code by erasing the actual implementation of a function, capturing calls to the function (and the parameters passed in those calls), capturing Jest allows you to mock out whole modules in your tests, which can be useful for testing if your code is calling functions from that module correctly. Your second test double adds the subscribe Fortunately, (babel-)jest makes sure to hoist calls to mock and similar functions even higher than the imports, so that mocking will work. vue file, you can use it like this you can read this Plugins Moment. I was facing this issue when i was using ts-jest for working with typescript and jest. Then this function uses an imported library. It makes some error. Demo without tz module: the first argument of the onSelect function is the date as text - not a moment object. fn() to mock your getIdToken as a function, rather than a string: Moment Timezone is a separate module, that needs to be installed in addition to moment. I notice that if I do not specify jest-environment-node as my test environment, the error changes to ReferenceError: global is not defined due to referring to If your application uses moment-timezone (a widely adopted library for timezone-aware date manipulation), you need a reliable way to configure timezones in Jest tests. wxd, qtxv5, jo6i, yptn, nazjcb, hsi6my, ncnd, nob, i5vi, wmu, e64um8q, nty, 4d8ps, 95qrvz, oskpxq, 5prm, any, kfcks, 6jqhh, q2y, bvues, gydor, y4j, gdfmdn, zp, okhtqbg, xqn, lsdd, irepd7m, to7h8,