[Unit testing] Vitest, mock Time
import { afterEach, test, expect, vi, beforeEach } from 'vitest';
import { render } from 'test/utilities';
import TimeZone from '.';
beforeEach(() => {
// freeze time
vi.useFakeTimers();
// set system time to a certain point
vi.setSystemTime(1679492355195);
});
test('it should render successfully', () => {
render(<TimeZone />);
});
test('should match the snapshot', async () => {
const { container } = render(<TimeZone />);
expect(container).toMatchSnapshot();
});
afterEach(() => {
vi.useRealTimers();
});