Exporting to Cucumber-JS

Automating features using NodeJS to export to Cucumber-JS.

Alan Parkinson avatar
Written by Alan Parkinson
Updated over a week ago

Behave Pro can export the created Feature and Scenarios to any gherkin compatible test automation tool. For JavaScript based projects we have a library that will export the features directly from Jira in a script or command line client.

Installation

The Behave Pro Node client is available from NPM, and can be installed using the following:

$ npm install behavepro -g

NodeJS and NPM are both required to be installed.

Using from the command line

Parameters can either be passed from the command line:

$ behavepro [–id PROJECT ID] [–userId USER] [–apiKey KEY]

Available parameters:

  • [–host HOST] Behave Pro host (or Jira Server instance url)

  • [–id PROJECT ID] Jira project id

  • [–userId USER] Cloud userId OR Jira Server Username

  • [–apiKey KEY] Cloud API key OR Jira Server Password

  • [–output DIRECTORY] Output directory - default: 'features’

  • [–manual] Include scenarios marked as manual

  • [–config CONFIG] JSON config file - relative to current directory

If the three required parameters are missing, they will be attempted to be read from a json config file in the current directory:

$ behavepro

config.json

 example

[{
    "id": 10000,
    "userId": "Cloud userId OR Jira Server Username",
    "apiKey": "Cloud API key OR Jira Server Password"
}, {
    "id": 10100,
    "userId": "Cloud userId OR Jira Server Username",
    "apiKey": "Cloud API key OR Jira Server Password"
}]

Using from within a script

You can use the client in your own scripts to download features from Behave Pro.

$ npm install behavepro –save

var BehavePro = require('behavepro');

BehavePro({
  "id": 10000,
  "userId": "Cloud userId OR Jira Server Username",
  "apiKey": "Cloud API key OR Jira Server Password"
}, function() {
  // done
});

Available parameters:

  • “host”: HOST - Behave Pro host - default: 'https://behave.pro’ OR Jira Server URL

  • “id”: ID - Jira project id

  • “userId”: USERID - Jira username

  • “apiKey”: APIKEY - Jira password

  • “output”: DIRECTORY - Output directory - default: 'features’

  • “manual”: true - Include scenarios marked as manual

The script has four required parameters, host , id , userId  and apiKey . These 4 parameters are different depending on if you are using Jira Cloud or Server. You can retrieve the correct details the Jira project's admin area; 'Project Settings' > 'Behave Pro' > 'Generate config'. This article has more information on finding these configuration items

Did this answer your question?