Skip to content
animorio
IT
Back to the library

Test coverage

Text, HoverGSAP, CSS onlyMediumCompressed weight: Demo 6.5 KBGSAP 28 KBFreeDownload the zip

Test coverage on a small function, in a card on black, minimal style: ten lines of code, each with its strip. “Run tests” marks them one after the other from the top: the green strip fills, the number of times the line ran comes in and the percentage counts up to 86. The line no test reaches stays hatched in amber, with its zero. Pointing at a line says what happened to it; “Add the missing test” takes everything to a hundred, with a light running along the bar.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Test coverage" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Test coverage</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- test coverage on a small function: running the tests marks the lines one by one, the line no test reaches
         stays hatched, the percentage counts, and pointing at a line says how many times it ran -->
    <section class="cv" data-cv aria-label="Test coverage">
      <header class="cv__head">
        <div class="cv__file"><strong>cart.js</strong><span class="cv__clip"><span data-outsum>Not measured yet</span></span></div>
        <span class="cv__pct" aria-hidden="true"><b data-outpct>0</b><i>%</i></span>
      </header>
      <div class="cv__bar" aria-hidden="true"><i data-bar></i><i class="cv__shine" data-shine></i></div>
      <ol class="cv__code" data-code aria-label="Source lines"></ol>
      <p class="cv__info"><span class="cv__clip"><span data-outinfo>Run the tests to see what they reach.</span></span></p>
      <button type="button" class="cv__btn" data-next><span class="cv__clip"><span data-outnext>Run tests</span></span></button>
    </section>
    <span class="live" aria-live="polite" data-live></span>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></path></svg>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

16 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Test coverage” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On black, a dark rounded card: “cart.js” and under it “Not measured yet”; on the right, large, “0%”. Below, a thin empty bar and a box with the code of a function that totals a cart: ten lines with their numbers on the left. Then the line “Run the tests to see what they reach.” and the light button “Run tests”. Tapping it, the lines are marked one after the other from the top: beside the number a green strip fills, the line’s text lights up and on the right comes how many times it ran, “4×”, “9×”. The seventh line, “sum = sum / 2;”, is reached by no test: its strip is hatched in amber, a diagonal hatch appears behind it, the line gives a small start and the count says “0×”. Meanwhile the percentage counts up to “86” and settles, the bar fills and under the name you read “6 of 7 lines covered”. Pointing at a line, below comes “Line 4 ran 9 times” or “Line 7 never ran: no test uses a code”. The button now says “Add the missing test”: tapping it the seventh line turns green, the counts go up, the percentage goes to “100” and a light runs along the bar.

How it works

One line, one object

Each line has its text and two numbers: how many times it runs with the current tests and how many with the extra one. Where there is nothing to run, no number.

The sweep

The lines take their state one after the other, staggered: the strip grows from the top and the count comes in from the right.

The missed line

Zero runs means a dashed strip, a hatch behind the line and the number zero: three signs, not just a colour.

The percentage

It is the count of lines run at least once over the runnable ones, and it climbs for the whole length of the sweep.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#5fe0a8The colour of the lines the tests reach.
PACEscript.js0.12How many seconds pass between one line and the next while the tests run.
SPRINGscript.js1How much the percentage bounces on landing.
LOOPscript.jstrueLeft alone, the demo’s pointer runs the tests, points at two lines and adds the missing test.

Try them in the Playground

When to use it

On the page of a testing or continuous integration tool, in the documentation of a library that wants to show how well tested it is, and in a developer’s portfolio. The same line-by-line sweep carries a spell check, a review or the reading of a contract.

On phones

The card is at most 348 pixels wide and about 345 tall: the code is at 10.5 pixels (10 under 350) and no line is longer than 31 characters, so it never wraps or gets cut. With a finger a tap on a line shows its text, another removes it.

With reduced motion

No sweep: strips, counts, hatch and percentage are in place at once, and the texts change in one step. The demo’s pointer does not start.

Pitfalls

  • The lines are an ordered list and each takes keyboard focus: what you read by pointing you also read with Tab.
  • The percentage counts runnable lines, not all of them: closing braces have nothing to run and do not weigh.
  • A hundred per cent of lines does not mean the code is right: it only says every line ran at least once.
  • The code is written as text and then coloured: special characters are escaped before becoming HTML.
  • Function, counts and names are invented.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 6.5 KB; the libraries: GSAP 28 KB.

Testing

Tested on 1 December 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations