Search code examples
javascriptdatetimeopentest

OpenTest Doesn't Take a Standard JS Date for the ReadEmailImap function


I am attempting to pass a value for sentAfter to org.opentest.ReadEmailImap function that contains a string formatted as YYYY:MM:DD HH:DD:MM per this documentation

The closest that I have come to this format is .toISOString(). ref


Solution

  • You can either build the date yourself using the JavaScript API, like here, or you can use a library like Moment.js (The moment.js file can be included in your test as described here). The first method is better for a quick and dirty, one time solution. The second is best if you have more advanced date/time logic that you need to execute.