npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@cucumber/react-components

v24.1.2

Published

React components for Cucumber

Readme

@cucumber/react-components

A set of React components for rendering Gherkin documents and Cucumber results.

Preview and examples:
https://cucumber-react-preview.netlify.app/

Examples Tables

Usage

  • This package is distributed in ES module format only.
  • React 18 or above is required.

The source code for the screenshot above is:

import { EnvelopesProvider, FilteredDocuments } from '@cucumber/react-components'

<EnvelopesProvider envelopes={envelopes}>
  <FilteredDocuments />
</EnvelopesProvider>

envelopes should be an array of Cucumber Messages that came from a test run. You can obtain these from most Cucumber implementations by using a "Message" formatter.

Attachments

Attachments from test runs are shown with their corresponding steps. The baseline behavior for attachments is a download button. However, we have some special handling for common MIME types to make them more useful without leaving the report:

  • image/* - images are rendered with an <img/> tag
  • video/* - videos are rendered with a <video/ tag
  • text/x.cucumber.log+plain - logs (from calls to the log function in Cucumber) are rendered as monospace text, and support ANSI colors
  • text/uri-list - one or more URLs are rendered as links that open in a new tab
  • application/json - JSON is rendered as monospace text and prettified
  • text/* - other text types are rendered as monospace text

Styling

The standard styling comes without any extra providers or configuration. There are several ways you can apply different styling to the components.

Theming

You can provide your own theme with a small amount of CSS. Target the element above your highest-level usage of the components:

<div className="dark-theme">
  <EnvelopesProvider envelopes={envelopes}>
    <FilteredDocuments />
  </EnvelopesProvider>
</div>

In your CSS, you can set the background and text colors, and override the supported custom property values as desired:

.dark-theme {
  background-color: #1d1d26;
  color: #c9c9d1;
  --cucumber-anchor-color: #4caaee;
  --cucumber-keyword-color: #d89077;
  --cucumber-parameter-color: #4caaee;
  --cucumber-tag-color: #85a658;
  --cucumber-docstring-color: #66a565;
  --cucumber-error-background-color: #cf6679;
  --cucumber-error-text-color: #222;
  --cucumber-code-background-color: #282a36;
  --cucumber-code-text-color: #f8f8f2;
  --cucumber-panel-background-color: #282a36;
  --cucumber-panel-accent-color: #313442;
  --cucumber-panel-text-color: #f8f8f2;
}

Custom styles

For more control over the styling, you can override the CSS used by individual components.

Let's say you want to do something totally different with the typography of doc strings. In your own CSS, you might write something like:

.acme-docstring {
  font-weight: bold;
  font-style: italic;
  background-color: black;
  color: hotpink;
  text-shadow: 1px 1px 2px white;
  padding: 10px;
}

Then, you can provide an overrides prop to the CustomRendering component, in the form of an object that declares which class names you're going to override and what with:

<CustomRendering overrides={{
  DocString: {
    docString: 'acme-docstring'
  }
}}>
  <EnvelopesProvider envelopes={envelopes}>
    <FilteredDocuments />
  </EnvelopesProvider>
</CustomRendering>

Some components have multiple styling hooks - e.g. the <Tags> component has the tags class name for the list, and the tag class name for each item. In these cases, you can provide custom class names for just the ones you want to change, and any you omit will pick up the built-in styling like normal.

Custom rendering

To change the rendering of some components entirely, you can selectively provide your own component implementations to be used instead of the built-in ones.

Staying with the doc string example, you can use the same overrides prop, but this time instead of an object with class names, you provide a React functional component, giving you full control over the rendering:

<CustomRendering overrides={{
  DocString: (props) => (
    <>
      <p>I am going to render this doc string in a textarea:</p>
      <textarea>{props.docString.content}</textarea>
    </>
  )
}}>
  <EnvelopesProvider envelopes={envelopes}>
    <FilteredDocuments />
  </EnvelopesProvider>
</CustomRendering>

In each case where you provide your own component, it will receive the same props as the default component, plus two more:

  • styles - class names for the default styling, so you can still apply these to your custom component if it makes sense
  • DefaultRenderer - the default React component, useful if you only want to provide your own rendering for certain cases, and otherwise fall back to the default rendering (don't forget to pass it the props)