Dialect Definitions for: 1.2.1
Show:

Variables Phrases

Variables Configures the Gherkin parser with phrases that support operations on variables

Methods

Assert Javascript

(
  • javascript
)

Assert some Javascript returns true or trigger a fail if return is 'falsey'

Parameters:

  • javascript String
    • inline javascript

Example:

 GIVEN I am testing
 THEN I assert this.name == "testing"

Assert JSON path matches RegExp

(
  • path
  • varname
  • regex
)

Assert that any array element in JSON path within a variable should match a regular expression (RegExp)

 $.hello in $varname should match $regex

Parameters:

  • path String
    • a valid JSON path
  • varname String
    • scoped variable
  • regex String
    • regular expression

Example:

 GIVEN I set variable my.hello to world
 THEN any $.hello in my should match a-z

Assert JSON path matches RegExp

(
  • path-
  • varname
  • regex
)

Assert some JSON path within a complex variable should match a regular expression (RegExp)

 $.hello in $varname should match $regex

Parameters:

  • path- String

    JSON path

  • varname String
    • scoped variable
  • regex String
    • regular expression

Example:

 GIVEN I set variable my.hello to world
 THEN $.hello in my should match a-z

Assert variable is truthy

(
  • varname
)

Assert some variable is assigned a value that is truthy

 variable $varname should exist

Parameters:

  • varname String
    • scoped variable

Example:

 GIVEN I set variable hello to world
 THEN variable hello should exist

Assert variable matches a value exactly

(
  • varname
  • value
)

Assert some variable should match an exact value

 variable $varname should be $value
 $varname should be $value
 $varname equals $value
 $varname is $value
 $varname = $value

Parameters:

  • varname String
    • scoped variable
  • value String
    • expected value

Example:

 GIVEN I set variable hello to world
 THEN variable hello should exist

Assert variable matches RegExp

(
  • varname
  • regex
)

Assert some variable should match a regular expression (RegExp)

 variable $varname should match $regex

Parameters:

  • varname String
    • scoped variable
  • regex String
    • regular expression

Example:

 GIVEN I set variable hello to world
 THEN variable hello should match a-z

Assert variable matches RegExp

(
  • varname
  • regex
)

Assert some JSON path should match a regular expression (RegExp)

 variable $varname should match $regex

Parameters:

  • varname String
    • scoped variable
  • regex String
    • regular expression

Example:

 GIVEN I set variable hello to world
 THEN variable hello should match a-z

Assert variable value contains some string

(
  • varname
  • value
)

Assert some variable should contain a value

 variable $varname should contain $value

Parameters:

  • varname String
    • scoped variable
  • value String
    • expected value

Example:

 GIVEN I set variable hello to world
 THEN variable hello should contain orl

Clear Variables

()

Remove all the scoped variables

 I clear variables

 I reset variables

Example:

 GIVEN I reset variables

Execute Javascript

(
  • javascript
)

Execute Javascript - trigger a fail if return is falsey

Parameters:

  • javascript String
    • inline javascript

Example:

 WHEN I execute (3+4)

Save Javascript to Variable

(
  • javascript
  • varname
)

Run Javscript and save result into a variable

Parameters:

  • javascript String
    • inline javascript
  • varname String
    • variable name

Example:

 GIVEN I return 2+3 as my-answer

 AND I return new Date().getTime() as now

Set Variable

(
  • variable
  • value
)

Set the value of a scoped variable

 I set $varname to $value

 I set $varname = $value

 I define $varname = $value

 I define $varname is $value

Parameters:

  • variable String
    • variable name
  • value Object
    • simple value (string | number | boolean)

Example:

 GIVEN I set hello to world
 AND I set yes to true
 AND I set nope to false
 AND I set answer to 42

Set Variable from CSV

(
  • name
  • CSV
)

Sets the value of a scoped variable to inline CSV data structure

 I set $varname to CSV:
 -------------
 $CSV
 -------------

 some $varname as CSV:
 -------------
 $CSV
 -------------

Parameters:

  • name String
    • variable name
  • CSV String
    • inline CSV text

Example:

 GIVEN I set my-csv to CSV:
 -------------
 hello, goodbye
 world, earth
 -------------

or:

 AND some CSV as my-csv:
 -------------
 hello, goodbye
 world, earth
 -------------

Set Variable from JSON

(
  • name
  • JSON
)

Sets the value of a scoped variable to inline JSON data structure


Parameters:

  • name String
    • variable name
  • JSON Object
    • inline JSON

Example:

 GIVEN I set $varname to JSON:
 -------------
 { "hello": "world" }
 -------------

or:

 AND some JSON as $varname:
 -------------
 { "hello": "world" }
 -------------