Hi,
First off, thanks for this. It helped us be able to test some code with date_fns that would have been a nightmare otherwise.
The problem:
If you have UI tests running in node then you have a window object and a global. The code at:
|
function register(new_timezone, glob) { |
|
if (!glob) { |
|
if (typeof window !== 'undefined') { |
|
glob = window; |
|
} else { |
|
glob = global; |
|
} |
|
} |
...assumes one or the other but not both.
As a workaround I'm doing:
timezoneMock.register(timezone);
global.Date = window.Date;
/// ...tests
timezoneMock.unregister();
global.Date = window.Date;
Hi,
First off, thanks for this. It helped us be able to test some code with date_fns that would have been a nightmare otherwise.
The problem:
If you have UI tests running in node then you have a window object and a global. The code at:
timezone-mock/index.js
Lines 265 to 272 in 780f8c2
...assumes one or the other but not both.
As a workaround I'm doing: