Skip to content
EspañolEnglish
All components (283)

Test results

AI · TestResults

What it is and when to use it

The result of a run of tests: how many pass, how many fail and how many are skipped, and underneath the groups with their tests.

When to use it

  • Showing what happened when running tests, whether by an agent or by continuous integration.
  • suites are the groups: { key, name, tests }, and each test { key, name, status, durationMs?, error? }. Groups with failures come out open and show the message.

When not to

  • The result of a single test: Alert or Result.
  • A table of data: Table.

Keyboard: each group folds with its title: Tab, Enter or Space.

Accessibility: the summary is a status region; the state of each test is seen through the icon and said with hidden text: colour is not the only thing that informs. Error messages go in a text block.

Fine-tuning: amset-testresults and the amset-testresults__* classes.

What it looks like

Some tests fail3 passed1 failed1 skippedin 171 ms

  • Doneadds up the products12 ms
  • Doneapplies the coupon8 ms
  • Failedrespects the per-customer maximum31 ms
    Expected 3, received 5
        at cart.test.ts:44:12

<TestResults
  label="Shop tests"
  suites={[
    { key: "cart", name: "Cart", tests: [{ key: "a", name: "adds up the products", status: "passed", durationMs: 12 }] },
  ]}
/>

Props

Import it with import { TestResults } from '@amset/ui'. Required props are marked.

PropTypeWhat it does
labelrequiredstringWhat was tested: "Shop tests". Required: it is the name of the region.
suitesrequiredreadonly TestSuite[]The groups of tests: `{ key, name, tests: [{ key, name, status, durationMs?, error? }] }`.
classNamestringMerged with the library classes; it does not replace them.

It also accepts the attributes of the element it renders: className, style, data-*, aria-* and its events.

In the test bench

Every state and variant, to try one at a time, on its page at storybook.amsetui.com: