I’m using grunt to package my jQuery plugin. As part of the QUnit tests, I need to run a node command before the tests start to get a consistent result (something like process.env.TZ = 'Europe/London' as my plugin deals with timezones, so results will be different in different timezones).
So my question is: How can you run a node specific command as part of the qunit tests?
Thanks.
Well, after a bit more research, I came across grunt-env @ https://github.com/onehealth/grunt-env
That allows different environment tasks to be defined in the gruntfile, e.g.
which will define the task
env:setTZto set the timezone. And yes, whilst setting the timezone can be problematic, advice appears to be that so long as you only do it the once, you’re OK: https://groups.google.com/d/msg/nodejs/rt8EFR6gdi8/i2Fdp2vDPFQJLuckily, that’s plenty sufficient for my use case, and it works just fine for me.