Nothing immediately jumps out that could be failing the test, but I do have a few comments on the code:
Using global values for a multi-threaded environment does not work. The same goes for asynchronous calls (this could be why the tests are failing). This is why you are encouraged (and taught) to use a database
It is confusing to send a status 200 with an error message: res.sendStatus(200).send("Invalid user id");
Unless I missed it, you do not use the fr and to variables
const fr = new Date(req.query.from).getDate();
const to = new Date(req.query.to).getDate();
I hope you figure out how to move forward with the tests, and hope this helps.