Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests are dependent on local timezone settings #41

Open
lennym opened this issue Jan 8, 2016 · 5 comments
Open

Tests are dependent on local timezone settings #41

lennym opened this issue Jan 8, 2016 · 5 comments

Comments

@lennym
Copy link

lennym commented Jan 8, 2016

I was running the tests locally by request of someone in the #Node.js IRC channel and noticed that I got a different set of test failures depending on the timezone settings of my computer.

With timezone set to GMT (my normal timezone):

  1) dateformat([now], [mask]) should format `longTime` mask:
     AssertionError: '1:19:44 PM GMT' === '1:19:44 PM UTC'
      at Context.<anonymous> (/Users/lenny/dev/node-dateformat/test/test_formats.js:64:14)
      at Test.Runnable.run (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runnable.js:217:15)
      at Runner.runTest (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:373:10)
      at /Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:451:12
      at next (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:298:14)
      at /Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:308:7
      at next (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:246:23)
      at Immediate._onImmediate (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:275:5)
      at processImmediate [as _immediateCallback] (timers.js:368:17)

  2) dateformat([now], [mask]) should format `expiresHeaderFormat` mask:
     AssertionError: 'Wed, 26 Nov 2014 13:19:44 GMT' === 'Wed, 26 Nov 2014 13:19:44 UTC'
      at Context.<anonymous> (/Users/lenny/dev/node-dateformat/test/test_formats.js:64:14)
      at Test.Runnable.run (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runnable.js:217:15)
      at Runner.runTest (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:373:10)
      at /Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:451:12
      at next (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:298:14)
      at /Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:308:7
      at next (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:246:23)
      at Immediate._onImmediate (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:275:5)
      at processImmediate [as _immediateCallback] (timers.js:368:17)

With my timezone set to EST:

  1) dayOfWeek should correctly format the timezone part:
     AssertionError: '7' === '1'
      at Context.<anonymous> (/Users/lenny/dev/node-dateformat/test/test_dayofweek.js:11:14)
      at Test.Runnable.run (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runnable.js:217:15)
      at Runner.runTest (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:373:10)
      at /Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:451:12
      at next (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:298:14)
      at /Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:308:7
      at next (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:246:23)
      at Immediate._onImmediate (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:275:5)
      at processImmediate [as _immediateCallback] (timers.js:368:17)

  2) dateformat([now], [mask]) should format `longTime` mask:
     AssertionError: '1:19:44 PM EST' === '1:19:44 PM GMT--500'
      at Context.<anonymous> (/Users/lenny/dev/node-dateformat/test/test_formats.js:64:14)
      at Test.Runnable.run (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runnable.js:217:15)
      at Runner.runTest (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:373:10)
      at /Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:451:12
      at next (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:298:14)
      at /Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:308:7
      at next (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:246:23)
      at Immediate._onImmediate (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:275:5)
      at processImmediate [as _immediateCallback] (timers.js:368:17)

  3) dateformat([now], [mask]) should format `isoDateTime` mask:
     AssertionError: '2014-11-26T13:19:44-0500' === '2014-11-26T13:19:44--500'
      at Context.<anonymous> (/Users/lenny/dev/node-dateformat/test/test_formats.js:64:14)
      at Test.Runnable.run (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runnable.js:217:15)
      at Runner.runTest (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:373:10)
      at /Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:451:12
      at next (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:298:14)
      at /Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:308:7
      at next (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:246:23)
      at Immediate._onImmediate (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:275:5)
      at processImmediate [as _immediateCallback] (timers.js:368:17)

  4) dateformat([now], [mask]) should format `expiresHeaderFormat` mask:
     AssertionError: 'Wed, 26 Nov 2014 13:19:44 EST' === 'Wed, 26 Nov 2014 13:19:44 GMT--500'
      at Context.<anonymous> (/Users/lenny/dev/node-dateformat/test/test_formats.js:64:14)
      at Test.Runnable.run (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runnable.js:217:15)
      at Runner.runTest (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:373:10)
      at /Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:451:12
      at next (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:298:14)
      at /Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:308:7
      at next (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:246:23)
      at Immediate._onImmediate (/Users/lenny/dev/node-dateformat/node_modules/mocha/lib/runner.js:275:5)
      at processImmediate [as _immediateCallback] (timers.js:368:17)
@simevo
Copy link

simevo commented Mar 13, 2017

Hi, we've encountered the same issue (the first variant) as part of the debian reproducible builds initiative:
https://bugs.debian.org/856830.

@kapouer
Copy link

kapouer commented Mar 14, 2017

Does setting TZ env var to a well-defined value fixes the issue ?

TZ='Pacific/Norfolk' mocha
TZ='CET' mocha

etc...

@simevo
Copy link

simevo commented Mar 14, 2017

Yep, that fixes the tests. This:

TZ=GMT mocha -R spec

fails whereas this:

TZ=UTC mocha -R spec

pass !

I consider this a workaround but enough for the Debian bug. Probably it would be best to solve the underlying issue though.

@kapouer
Copy link

kapouer commented Mar 14, 2017

Note that

TZ='D' node -p '(new Date).toString()'
> Tue Mar 14 2017 17:59:14 GMT+0000 ()

TZ=GMT node -p '(new Date).toString()'
> Tue Mar 14 2017 18:01:36 GMT+0000 (GMT)

so fixing this might be a bit weirder than it looks.

@kapouer
Copy link

kapouer commented Jan 7, 2019

This is still true, especially with node 10.15 where UTC does not appear in timezones, only GMT+xxxx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants