1.0.9 • Public • Published


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


npm install @bbc/cucumber-slicer --save


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

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

runCucumberTests('./generatedFeatures/**/*.feature').then(() => {

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.


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.

Package Sidebar


npm i @bbc/cucumber-slicer

Weekly Downloads






Unpacked Size

44.7 kB

Total Files


Last publish


  • tiposupport
  • glennalcock
  • codedbypaul
  • darkoa01
  • anatdeanbeeb
  • ghazif03
  • ndbbc
  • yonglexu
  • san-rai
  • y.million
  • ridwan_dev
  • jpark0224
  • kieranjoyce
  • helen_morris
  • olssod02
  • aliciagrandjean
  • laura01
  • thsolomon
  • aabbabar
  • james.bungay
  • albertlobbc
  • welshl02
  • fglover84
  • yoshihirokasahara
  • fullerlee-bbc
  • tamsingreen
  • jkordekbbc
  • shanthichaitanya
  • biguzc01
  • m-mafeni
  • ryanmcbbc
  • ken0310
  • george-brooke
  • j-e-boreham
  • tmoco
  • jpeutherer1
  • allbutterg
  • tomchamberlainuk
  • dio-p
  • deepaakhil
  • simm90
  • claydelas
  • fahad-75
  • chalikov
  • macgll01
  • eloisec
  • urbanm13
  • wormab01
  • alistair.gempf
  • johnsn27
  • olivierhuinbbc
  • sgospodinov
  • jezbur-bbc
  • cps-support
  • arunbhari11
  • matthewcard
  • samcauser
  • thomsonp
  • mcmanj04
  • neha0508
  • lewer
  • tarqwyn
  • petra-at
  • danm
  • langtonm
  • chrismarsden
  • daramaguire
  • eamonnsullivan
  • coderkind
  • leobs
  • cardl01
  • parwiz_sharifi
  • garethjdavies
  • norrid02
  • priyapolineni
  • chrispnicholson
  • jacobpryce
  • mattgreenham
  • newslabs-jenkins
  • sarahrainbow
  • farahjabri