Track your test duration
Tags: redishackathon, testing, javascript
Published: 2022-08-29 18:36:00

Have you ever increased your test duration by upgrading some dependencies, changing a configuration, ... ?

That happened to me, and that's why I made this project that tracks the duration of each test in a project as well as the timing to run all the tests.

> **Note:** This is a special post to show my Redis Hackathon submission

## Overview of My Submission

Redis Timing Tracker will help you to track all the duration of your test. This is useful to know when your time execution suddenly increased.

<u>All test page overview</u>

![All test page overview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gev92ezec3e433gascxf.png)
 
<u>Single test page overview</u>

![Single test page overview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yfku2tna2btuduahpjup.png)
 

Thanks to graphs, you can easily see the evolution of timings. Each point corresponds to a run, and by clicking on it you can see the commit SHA, to look at what are the changes that has been made.

Of course, if the duration increases that doesn't mean that there is a regression, it can also be due to the add of tests. So you can see number of test executed for a run by clicking on the point.

If there is any point that complicates the read of the graph you can delete it temporarily of the graph to have a better curve or even permanently from the database.

It also detects if the current test did not run at the last execution which probably mean that it has been removed from tests.

You can see it in action: https://redis-timing-tracker.vercel.app/

> **Note:** For now the tracking only works with Jest. And take into account only tests that don't have any error. The full test duration is not persisted if there is a test in error.

----

Let's see the architecture of the project:

![Architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ssqwss26elg2uu2po11e.png)

I developed a Jest reporter that needs to be added on the project to track its execution test timing.
This reporter will publish the following data on a topic:
- **execution of each test**
- **the total execution duration**

Then there is a script that subscribes to that topic to process the previous messages.
For example it will store the duration for each started time on a Time Series to display the graph, the info in JSON format to get the information of each run at click. You can see all the information on the [README.md](https://github.com/romain-trotard/redis-timing-tracker/blob/main/README.md).

## Submission Category

I submit this project for the Wacky Wildcards.

### Language Used

JS/TS/Node.js.


## Link to Code

{% embed https://github.com/romain-trotard/redis-timing-tracker %}


### Additional Resources / Info

I developped the BO with [Next JS](https://nextjs.org/) and used [Chakra UI](https://chakra-ui.com/) to build the frontend UI.

I used [recharts](https://recharts.org/) to draw my graphs.

For the database, I use the [node-redis](https://github.com/redis/node-redis) client. And used the following modules:
- [RedisJSON](https://redis.io/docs/stack/json/)
- [RediSearch](https://redis.io/docs/stack/search/)
- [RedisTimeSeries](https://redis.io/docs/stack/timeseries/)

- - - 

* _Check out [Redis OM](https://redis.io/docs/stack/get-started/clients/#high-level-client-libraries), client libraries for working with Redis as a multi-model database._
* _Use [RedisInsight](https://redis.info/redisinsight) to visualize your data in Redis._
* _Sign up for a [free Redis database](https://redis.info/try-free-dev-to)._