amirelemam / simulateTimeUnitTests

How to simulate time in a unit test with Jest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simulate Time in Unit Tests

This project is an example of how to simulate time on an unit test.

Use case

Let's say your system should perform regular backups every day at midnight. In order to test the function that backs up the system, you need to simulate that's midnight when the test run. Here's how to do that!

Instalation

  1. Install dependencies
$ npm install
  1. Run tests
$ npm test

Tutorial

[Medium[(https://amirelemam.medium.com/simulate-time-in-a-unit-test-c2fb86f29254)

License

These files are licensed under the MIT License

About

How to simulate time in a unit test with Jest

License:MIT License


Languages

Language:JavaScript 100.0%