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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bbc/cucumber-slicer

v1.0.9

Published

Split cucumber feature files into a separate file for each scenario

Downloads

742

Readme

cucumber-slicer

Split cucumber feature files into a separate file for each scenario.

Installation

npm install @bbc/cucumber-slicer --save

Usage

const glob = require('glob');
const cucumberSlicer = require('@bbc/cucumber-slicer');

const featureFiles = glob.sync('./features/**/*.feature');
const generatedFiles = cucumberSlicer(featureFiles,
'./generatedFeatures');

runCucumberTests('./generatedFeatures/**/*.feature').then(() => {
  removeGeneratedFeatures(generatedFiles);
});

How it works

The cucumberSlicer goes through each of the feature files and creates a separate file out of each scenario. The generated files are meant to be transient. They only include what is necessary to run the test -- no comments or extra explanatory text. What is copied over are any feature-level tags, the feature title, any background steps, any scenario-level tags (e.g., @wip) and the scenario with all of its steps or table data.

To avoid creating too many files in a directory, the generator uses the first feature-level tag (if any) as a subdirectory name.

If you don't want one or more of the feature files to be split, add the tag @nosplit to the feature-level tags. All of the scenarios in that file will be kept in the resulting generated one.

Why?

Many test automation infrastructures, such as Browserstack or Sauce Labs, run the feature files in parallel. However, if you write Gherkin/cucumber files in the normal way, you'll have several scenarios per feature. This means those scenarios are run as a group. There are various ways to address this (see parallel-cucumber, for example). The easiest way we found -- without having to change any of our other tools -- was to use cucumber in the normal way and split the tests into individual scenarios when we wanted to run them on Browserstack or similar environment. We get the benefit of managing feature files in the way we are used to, with scenarios grouped by major feature, while still getting reasonable performance from automated tests.

You will need to write the scenarios so that they are capable of running in parallel, which is tricky if your tests access a shared database. The @nosplit tag allows you to run some of your scenarios sequentially.