Somehow after a Docker image rebuild, I started having problems with javascript timezone problem. It used to work, but after a Docker image update, somehow the resulting Date object does not obey the TZ setting anymore. As the result, our timezone depending Date string formatting tests are failing.
# in the tests
console.log(new Date("2016-04-01T00:00:00.000000+00:00"));
// It is very strange it says (Asia) at the end.
// In fact, it will say whatever I put in TZ
Fri Apr 01 2016 00:00:00 GMT+0000 (Asia)
# in Chrome developer tool
console.log(new Date());
Fri Apr 01 2016 08:00:00 GMT+0800 (CST)
gulpfile.js
gulp.task('test', ['_set_tpe_timezone'], runKarmaWebpackTests);
gulp.task('_set_tpe_timezone', function() {
gutil.log('Setting timezone TZ = Asia/Taipei');
process.env.TZ = 'Asia/Taipei';
return;
});
I am using the following setup to run javascript tests:
- Gulp + Karma
- inside a Docker container
- In gulpfile, execute the following setting before each test
process.env.TZ = 'Asia/Taipei';
- using headless Chrome 59
cat /etc/timezone
=Etc/UTC