DEV Community

Romain Trotard
Romain Trotard

Posted on

Track your test duration

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.

All test page overview

All test page overview

Single test page overview

Single test page overview

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

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.

Submission Category

I submit this project for the Wacky Wildcards.

Language Used

JS/TS/Node.js.

Link to Code

Redis Timing Tracker

What is it?

Track the timing of your jest tests to follow the evolution of time passed for each test.

This way you can know when a change in your configuration, a library upgrade or a change in your test, increased drastically the time passed on your tests.

All test page overview

All test page overview

Single test page overview

Single test page overview

The Back Office is deployed here: https://redis-timing-tracker.vercel.app/

Note: For now, it doesn't persist data of a test in error, and if there is an error it doesn't persist the full execution duration.

How it works

Here is little achitecture diagram:

Architecture diagram of the project

Stack used

Type structures are written with Typescript.

In this project I use 3 services of the Redis Stack:

  • Redis pub/sub
  • RedisJSON
  • RediSearch
  • RedisTimeSeries

Pub/sub messages

Before looking at how the data is stored. It's important to see how Redis pub/sub is used Events are published and subscribed to a topic …

Additional Resources / Info

I developped the BO with Next JS and used Chakra UI to build the frontend UI.

I used recharts to draw my graphs.

For the database, I use the node-redis client. And used the following modules:


Top comments (0)