In my test, I want to fill and assert the value of some date / datetime fields. Some of these date / datetime fields have validations are validated in order to prevent users from submitting dates in the past. In order to achieve this stumbled upon the
moment module, which provides an easy way for getting, setting, and presenting dates. I noticed that
moment is one of the dependencies of TestCafé, so there was no need to import the module. I just had to import the module, which I achieved through the following statement.
import * as moment from 'moment';
In my test I subsequently call the
moment() function in order to get the current date. As our application expects the date to be formatted according to a specific format, I wrote a helper function to achieve that for any moment. When running the test TestCafé, however, throws an error at creating the moment.
TypeError: moment is not a function
It seems as I cannot call the moment module from a test. Is there any way to solve this?