vendredi 25 décembre 2020

How to mock "NOW()" for TypeORM MySQL?

I use Jest for testing and TypeORM as ORM, MySQL is the database.

I have a time-dependent query, which will return the results if the DAY(NOW()) is lesser than 27.

.andWhere('DAY(NOW()) <= 27')

I don't want my tests to break on 28th, how should I mock/replace it on Database?

Is there more elegant way?

Thank you

Aucun commentaire:

Enregistrer un commentaire