[Vuejs]-Snapshot shows timezone name instead of GMT code in CI server

0👍

Using Date strings as props like this is hazardous and likely to lead to the sort of problem you’re encountering.

Best practice for tests in my experience is to use Date.getTime() so values are numbers of milliseconds without any locale information.

Alternatively, you can use moment-timezone as described in this article:

import moment from 'moment-timezone';

it('renders without crashing', () => {
  moment.tz.setDefault('EST');
  let props = {
    currentDay: moment("2017-09-15 09:30:00").format("MMM Do YYYY h:mm:ss a")
  };

  const tree = renderer.create(<App {...props} />).toJSON();
  expect(tree).toMatchSnapshot();
});

Leave a comment