cucumber-expression-extender
Prerequisites | Installation | Manual
Cucumber expression extender is a simple Cucumber's plugin to extend the tags expressions for easier feature files writings.
Why
It helps writing cleaner feature files without complex regular expressions.
Writing something like
Given 21-11-2015 is nice
can be translated by
Given('{dd-mm-yy} is nice '
Instead of:
Given(/^(\d+)\-(\d+)\-(\d+) is nice$/
Prerequisites
In order to use this plugin:
- Cucumber must be installed.
Installation
To install the plugin to your project please use:
npm install cucumber-expression-extender
Manual
Once Cucumber expression extender is installed,
you can require it in your project:
require('cucumber-expression-extender');
And that's it,
you can now integrate it in your step definitions:
Given('{dd-mm-yy} is a nice date',
(dateObject) => {
console.log('indeed nice date ',
dateObject.toString());
});
And you can use the new step in feature file
Given 01-02-21 is a nice date
Supported types
expression | what is it | examples |
---|---|---|
dd-mm-yy | date pattern day(2 digits), month(2 digits), year(2 digits) | 19-11-89, 19/11/89 |
mm-dd-yy | date pattern month(2 digits), day(2 digits), year(2 digits) | 11-19-89, 11/19/89 |
dd-mm-yyyy | date pattern day(2 digits), month(2 digits), year(4 digits) | 19-11-1989, 19/11/1989 |
mm-dd-yyyy | date pattern month(2 digits), day(2 digits), year(4 digits) | 11-19-1989, 11/19/1989 |
non-space | any keyboard letters which are not spaces/tabs/new lines | 312!`,.?; |
env | value stored in process.env[KEY] | ENV["KEY"] or ENV['KEY'] |
array | list of values separated by a comma "," | a,b,b,c,!,` |
int-array | list of integer values separated by a comma "," | 1,2,30,6 |
base2-array | list of base2 (binary) values separated by a comma "," | 1,001,110,101 |
base8-array | list of base8 (octal) values separated by a comma "," | 3,4,57,70 |
base16-array | list of base16 (hex) values separated by a comma "," | 4,5,C,FFF |
float-array | list of float values separated by a comma "," | 1.0,2.3,4.3589 |
bool | string value represnting true/false values | true or TRUE or True or false or FALSE or False |
bool-array | list of boolean values separated by a comma "," | true,FALSE,False,TRUE,True,false |
json | json structrue to later be converted to object
ensure you specify a valid JSON data |
{"a":1, "b":2, "c":5, "e":"f"} |