Quick Start

Write and run your first automated test with TestFlowKit

Quick Start

In this tutorial, you'll learn how to set up a test project and write your first automated test with TestFlowKit.

Prerequisites

Before starting, make sure you have TestFlowKit installed:

npm install -g @testflowkit/cli
tkit --version
npx @testflowkit/cli --version
# Download from GitHub Releases
# https://github.com/TestFlowKit/testflowkit/releases
./tkit --version

What We'll Build

We'll create a simple test that:

  1. Visits a web page
  2. Interacts with a search field
  3. Verifies the search results

Step 1: Create Project Structure

Create a new folder for your test project with the following structure:

my-test-project/
├── config.yml
└── features/
    └── search.feature

Step 2: Create Configuration File

Create a config.yml file in your project folder:

settings:
  page_load_timeout: 30000
  think_time: 100
  concurrency: 1
  report_format: "html"
  gherkin_location: "features"

env:
  base_url: "http://localhost:3000"

frontend:
  base_url: "{{ env.base_url }}"
  default_timeout: 1000
  headless: false
  screenshot_on_failure: true
  
  pages:
    sentences: "sentences"

  elements:
    common:
      search_field:
        - "#search-input"

Configuration Breakdown

SectionPurpose
envEnvironment variables like frontend and API URLs
settings.page_load_timeoutMaximum wait time for page loads (ms)
settings.think_timeDelay between actions (ms) for debugging
settings.report_formatOutput format for test reports
settings.gherkin_locationFolder containing feature files
frontend.default_timeoutDefault timeout for element interactions (ms)
frontend.headlessRun without visible browser window
frontend.screenshot_on_failureCapture screenshots when tests fail
frontend.pagesNamed page paths
frontend.elementsElement selectors grouped by page with fallbacks

Step 3: Write Your First Test

Create a search.feature file in the features folder:

Feature: Search Functionality

  Scenario: User can search for sentence
    Given the user goes to the "sentences" page
    When the user enters "field" into the search field
    Then the user should see "the user enters {string} into the {string} field" on the page

Understanding the Syntax

  • Feature: Describes the feature being tested
  • Scenario: A specific test case
  • Given: Sets up the initial state
  • When: Describes the action
  • And: Adds additional actions or assertions
  • Then: Describes the expected outcome

Step 4: Run Your Test

Open a terminal in your project folder and run:

tkit run

TestFlowKit will:

  1. Read your configuration
  2. Launch the browser
  3. Execute your test steps
  4. Generate a report

Step 5: View the Report

Open the generated HTML report in your browser to see detailed test results, including:

  • Pass/fail status for each step
  • Execution time
  • Screenshots (on failure)

Common Commands

CommandDescription
tkit runRun all tests
tkit run --tags @smokeRun tests with specific tag
tkit run --headlessRun in headless mode
tkit validateValidate configuration
tkit initInitialize a new project

Next Steps

Congratulations! You've written and run your first TestFlowKit test. Continue learning: