Skip to main content

REPL Console

Interactive Gwen shell

Since v1.0.0

Gwen comes with a REPL (Read-Eval-Print-Loop) console. This is a command line shell that prompts you for steps, evaluates them, and outputs their status in real time. It enables you to experiment and observe the execution of steps as you enter (or paste) them which is very useful for debugging and analysis. Everything you enter is stored in a local history file and you can use the up and down arrow keys to recall previous inputs.

   __ ___      _____ _ __     _    
/ _` \ \ /\ / / _ \ '_ \ { \,"
| (_| |\ V V / __/ | | | {_`/
\__, | \_/\_/ \___|_| |_| `

Welcome to gwen-web v<version>

INFO - Default Gherkin feature dialect is: en
INFO - Environment context initialised

REPL Console

Enter steps to evaluate or type exit to quit..


Starting the REPL

To start a REPL session, invoke the Gwen CLI without specifying the -b (or --batch) switch.


To open a new REPL session:

yarn gwen

To load meta and open the REPL:

yarn gwen -m path/to/file.meta

To execute a feature and open the REPL:

yarn gwen path/to/file.feature

REPL commands

Once in the REPL, you can type help at the gwen> prompt to list the available commands.

Gwen REPL commands:

Displays this help text

env [switch] ["filter"]
Lists attributes in the current environment
Only lists visible attributes if no options are specified
switch : (optional)
-a : to list all attributes in all scopes
-f : to list all attributes in the feature (global) scope
filter : (optional) literal string or regex filter expression

Enters paste mode (for evaluating multiline steps)

Lists all previously entered commands

Executes a previously entered command (history bang operator)
# : the history command number

Given|When|Then|And|But step-expression
Evaluates a step
step-expression : the step expression

Closes the REPL session and exits

If in paste mode: exits paste mode and interprets provided steps
Otherwise: Closes REPL session and exits

Press the tab key for tab completion

Continue executing from current breakpoint step (debug mode only)

Tab completion

You can press the tab key at any time to lookup and select available commands, DSL Steps and custom StepDefs.

Paste mode

Should you attempt to enter a multiline step into the REPL, you will quickly discover that the first line will execute and fail as soon as you enter it without waiting for you to enter the remaining lines first. To address this, we have introduced a paste mode.

To enable paste mode, type :paste into the REPL prompt. The following will appear..

gwen> :paste

REPL Console (paste mode)

Enter or paste steps and press ctrl-D to evaluate..

You will then be able to enter or paste a multiple step without anything being executed when you press the enter key for each new line. For example, you could enter the following without any lines being executed prematurely:

 When the following items are added
| Item |
| Get the milk |
| Walk the dog |

Then when you're ready to execute or want to exit the paste mode, insert a new empty line at the end and press press cntl-D. The REPL will then evaluate the step you entered before the empty line and return to the standard prompt when done.

Exiting paste mode, interpreting now..

gwen> When the following items are added
| Item |
| Get the milk |
| Walk the dog |

INFO - Evaluating Step: When the following items are added
REPL Console

Enter steps to evaluate or type exit to quit..


Exiting the REPL

To exit the REPL, enter q, quit, exit, or bye or press ctrl-D at the gwen prompt.