LetsFlow
  • Introduction
  • Tutorial
    • The basics
    • A handshake
    • A conversation
    • A proper introduction
    • Group meeting
    • Quote
  • Cookbook
  • ENGINE
    • Installation
    • Authentication
    • API
    • Services
      • Configuration
      • Messaging
        • ZeroMQ
        • AMQP 0-9-1
        • Webhook
      • Engine service
  • Integration
    • Frontend
      • React
      • Angular
      • Vue
      • Svelte
    • Backend
  • Reference
    • Scenario
      • Actor
      • Action
        • Update instruction
      • State
        • Transition
          • Log
        • Notify
      • Data function
    • Schema
    • Process
      • Current state
      • Previous log
      • Prediction
      • Events
        • Instantiate event
        • Action event
        • Timeout event
  • Libraries
    • Core library
    • JMESPath
    • Test suite
      • Given
      • When
      • Then
        • Assert state
        • Assert actor
        • Assert variable
        • Assert service
        • Assert event
      • Customize
  • Advanced topics
    • Deep integration
    • Decentralized workflows
    • Custom JMESPath functions
    • Custom YAML tags
Powered by GitBook
On this page
  • Create a project
  • My first scenario
  • Running a test
  • Congratulations!

Was this helpful?

  1. Tutorial

The basics

Running your first workflow

PreviousTutorialNextA handshake

Last updated 1 month ago

Was this helpful?

In this tutorial, we'll create a new Node.js project, install the test suite, and run our first workflow.

Create a project

Use npm, yarn, or pnpm to create a new project. Install and the LetsFlow test suite.

yarn init
yarn add --dev @cucumber/cucumber @letsflow/testing

Copy the cucumber configuration from the test suite and create directories from the scenario and test files.

cp node_modules/@letsflow/testing/cucumber.example.yaml ./cucumber.yaml
mkdir scenarios features

Edit package.json and add the test:workflows script.

  "scripts": {
    "test:workflows": "cucumber-js --profile workflows"
  }

My first scenario

The scenario describes the process we're automating. We can write a scenario in either JSON or YAML.

Create file basics.yaml (or basics.json) in the scenarios directory.

A scenario has states. A new process will always start in the "initial" state. We define that if we perform the "complete" action, the process will transition to the "(done)" state.

basics.yaml
states:
  initial:
    on: complete
    goto: (done)
basics.json
{
  "states": {
    "initial": {
      "on": "complete",
      "goto": "(done)",
    }
  }
}

A state with a name in parenthesis, like "(done)", is an end state. There are no transitions from an end state. Unlike normal states, end states can be used in a goto statement without defining them explicitly.

Running a test

The LetsFlow test suite comes with a predefined set of statements that can be used to test running a scenario.

Create file basics.feature in the features directory.

basics.feature
Feature: Run a simple process that is completed in one step

  Background:
    Given the process is created from the "basics" scenario
    And "Joe" is the actor

  Scenario:
    When "Joe" does "complete"
    Then the process ended

Run the test from the command line

yarn test:workflows features/basics.feature

Congratulations!

You've successfully created and tested your first workflow.

The scenario can be tested by writing a BDD test in the language. Gherkin uses a set of special keywords to give structure and meaning so the test can be executed.

cucumber
Gherkin