Date field fails using .any and .anything

28 views Asked by At

I am writing Jest snapshot tests. I have a field that is a date string and it always fails the snapshot. I've tried testing:

expect(reducer(initialModel, action)).toMatchSnapshot({
  startDate: expect.any(Date),
});

however, that fails. I've also tried expect.anything() and the snapshot fails on the date:

-   "startDate": "2023-12-18T23:23:16.731-07:00",
+   "startDate": Anything,

Why is this failing?

0

There are 0 answers