I have very simple case scenarios, where I need to wait for few seconds before doing further execution.
I tried to set timeout function separately, exporting module or function only. nothing seems to work.
module.exports.tests = async () => {
console.log("inside test function")
await new Promise(async (resolve: any) => {
setTimeout(resolve, 5000);
});
// Do actual work
console.log("Starting actual work");
}
When I call this function
./node_modules/.bin/ts-node -e 'require(\"./src/tests.ts\").tests()
I would expect this to print "Starting actual work", But it never reaches there. It is printing "inside test function" and returning before calling actual work. What possibly I'm doing wrong here?