Hi! I have completed the timestamp microservices project. I have written couple test cases. when I ran the test script I got 2 cases passed but I got an assertion error later. Can you please tell me why I got that error? And how can I improve my test cases?
I’m not sure but I’m guessing the issue is with this line.
Keep in mind that Date.now() is in milliseconds so even a slight delay would cause this to fail. I would suggest checking that it is close instead of equal.
I have tried using chai-datetime but couldn’t implement it properly.
unixDate in the test to see exactly what they are because they may not be the same types even (one may be a number and one a
Date(), for instance. If they are both
Date() objects and just different in the milliseconds, your choices are to use
chai-datetime or to subtract the values in milliseconds and
assert() that they are less than some small value.
My advice is to save yourself the headache and get
chai-datetime doing the work for you, but beware that it wants
Date() objects as inputs and will error out otherwise.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.