Siddarth Kumar d6c899be3d
make sure nodejs uses a fixed timezone (#14793)
* make sure node uses the UTC timezone
  we have a few timebomb tests in the codebase that would break and making sure node specifies a timezone fixes them.
2023-01-16 16:34:15 +05:30

31 lines
702 B
JavaScript

var Mocks = require('../target/mocks/mocks.js');
var Module = require('module');
process.env.TZ = 'Etc/UTC'
const originalLoader = Module._load;
/*
Hook `require` so that RN abuse of require does not break when running tests in nodejs.
*/
Module._load = function hookedLoader(request, parent, isMain) {
if (request.match(/.jpeg|.jpg|.png$/)) {
return { uri: request };
}
return originalLoader(request, parent, isMain);
};
var originalRequire = Module.prototype.require;
Module.prototype.require = function(req){
module = Mocks.mocks(req);
if (module == null) {
return originalRequire.apply(this, arguments);
}
else {
return module;
}
};