About the course
Effective collaboration and a shared understanding of system behaviour are paramount for successful software delivery. Behaviour-Driven Development (BDD) provides a highly effective framework for fostering this collaboration by defining system behaviour through concrete, human-readable examples. This 3-day hands-on training course is specifically designed for JavaScript professionals who want to master the automation of these behaviours using Cucumber.js, the popular and capable open-source BDD framework for the Node.js environment. Participants will gain the practical skills to translate collaborative specifications into robust, maintainable, and automated acceptance tests that serve as valuable living documentation.
The course begins by reinforcing core BDD fundamentals and providing a deep dive into the Gherkin language, enabling participants to write clear, concise, and unambiguous feature files that accurately describe system behaviour from a user's perspective. Participants will then transition to mastering the core techniques of automating these specifications with Cucumber.js, learning how to set up a project, link Gherkin steps to executable JavaScript/TypeScript code by writing Step Definitions, and effectively work with structured data using DataTables. A significant portion explores using the Cucumber.js World object and hooks for safely managing and sharing state between steps within a scenario, a fundamental technique for building well-structured automation in JavaScript.
While Cucumber.js is the primary framework used for demonstration throughout the syllabus, the principles, patterns, and automation strategies taught are applicable across various BDD automation tools and testing frameworks in the JavaScript ecosystem.
We can customise the delivery of this course to integrate with or specifically focus on how Cucumber.js works alongside other popular JavaScript testing and automation frameworks such as Playwright, Selenium WebDriver, Cypress, Jasmine, and Mocha, showing how to use Cucumber.js to orchestrate end-to-end, API, or even integration tests executed by these tools. This flexibility allows tailoring the course to the specific automation tools your team already uses or plans to adopt. Note: We also offer a separate course specifically focused on Playwright test automation using a TDD approach, which complements this BDD-focused course.
Instructor-led online and in-house face-to-face options are available - as part of a wider customised training programme, or as a standalone workshop, on-site at your offices or at one of many flexible meeting spaces in the UK and around the World.
-
- Explain key BDD fundamentals and write clear specifications using Gherkin syntax (Given-When-Then).
- Set up and configure a BDD automation project using the Cucumber.js framework.
- Write Step Definitions in JavaScript/TypeScript that effectively link Gherkin steps to executable code.
- Work with structured data in scenarios using Cucumber.js DataTables.
- Manage and share state safely between steps using the Cucumber.js World object and hooks.
- Structure and organise Cucumber.js feature files and step definitions for maintainability and scalability.
- Implement patterns for automating interactions with different application layers
- Manage complex data scenarios using techniques like Composite Steps and Scenario Outline.
- Run Cucumber.js tests from the command line, interpret reports, and integrate tests into CI pipelines.
-
This 3-day hands-on training course is designed for JavaScript Developers, Quality Assurance (QA) professionals, and Automation Engineers who work within the JavaScript ecosystem and want to learn how to effectively automate Behaviour-Driven Development specifications using the Cucumber.js framework. It is ideal for:
JavaScript teams that are adopting BDD or need to automate their existing Gherkin specifications.
JavaScript developers and QAs who want to build robust, maintainable, and collaborative automated acceptance tests.
Automation engineers focusing on JavaScript applications who are looking to learn Cucumber.js and best practices for structuring automation frameworks.
Anyone involved in defining and verifying requirements for JavaScript applications who wants to gain practical skills in BDD automation.
-
Participants should have:
Practical experience with software development or testing in the JavaScript / Node.js environment.
Attended our intro to BDD workshop or have equivalent experience - for instance a basic understanding of Behaviour-Driven Development (BDD) principles (what BDD is, why use it, the concept of Gherkin scenarios).
A development environment set up for JavaScript development, with Node.js and npm installed, and a suitable IDE or code editor. Familiarity with package management, promises, and asynchronous JavaScript (async/await) is highly helpful for automation.
This course is hands-on and focuses on the automation aspects of BDD using the Cucumber.js framework.
Get in touch to find out how we can deliver tailored training which focuses on your project requirements and learning goals.
-
This BDD with JavaScript course is available for private / custom delivery for your team - as an in-house face-to-face workshop at your location of choice, or as online instructor-led training via MS Teams (or your own preferred platform).
Get in touch to find out how we can deliver tailored training which focuses on your project requirements and learning goals.
-
BDD Fundamentals Review
Quick review of Behaviour-Driven Development (BDD) principles and benefits.
The importance of collaboration (The Three Amigos) and shared understanding.
The Discovery phase: Exploring requirements using examples (Example Mapping/Specification by Example).
The Formulation phase: Writing good BDD scenarios.
Good and bad scenario writing patterns (The 6 BRIEF principles).
Separation of problem domain (Gherkin) and solution domain (automation code).
Hands-On Lab: Collaborative exercise on Example Mapping for a feature, writing initial Gherkin feature files.
Gherkin Syntax Deep Dive
The Purpose and Structure of Gherkin Feature Files (Feature, Scenario).
Keywords: Given, When, Then - defining context, action, and outcome.
Connecting Steps: And, But.
Providing Context: Background.
Testing Multiple Examples: Scenario Outline and Examples table.
Organising Features: Using Tags (@tagname).
Writing Clear, Concise, and Unambiguous Gherkin.
Hands-On Lab: Writing comprehensive Gherkin Feature files and Scenarios using all key syntax elements, ensuring clarity and adherence to best practices.
Introduction to Cucumber.js
What is Cucumber.js? Its role as a leading JavaScript BDD automation framework.
Installing Cucumber.js using npm.
Setting up a Cucumber.js project structure (e.g., features directory, step-definitions, support).
Understanding the role of support files and Hooks (e.g., Before, After, BeforeAll, AfterAll) for setup and teardown using hooks.js/.ts.
Basic Cucumber.js workflow: Writing a feature, writing step definitions, running cucumber-js.
Hands-On Lab: Setting up a new Node.js project and installing Cucumber.js, creating initial directories, writing a first simple feature file and running cucumber-js (demonstrating step definition hints), creating a basic support file with hooks.
Writing Step Definitions with Cucumber.js
What are Step Definitions in Cucumber.js? The JavaScript/TypeScript code implementation of Gherkin steps.
Matching Gherkin steps to Step Definition functions (Given, When, Then functions).
Using Regular Expressions vs. Cucumber Expressions for step matching and parameter extraction.
Parameterising Steps: Extracting data from Gherkin text into Step Definition function parameters.
Handling asynchronous operations (async/await, Promises) in Step Definitions.
Organising Step Definition files (.js or .ts) within the step-definitions directory.
Best practices for writing maintainable and reusable Step Definitions in JavaScript/TypeScript.
Hands-On Lab: Writing Step Definitions in JavaScript/TypeScript for the Gherkin scenarios from previous labs, implementing the necessary code (including async operations) to make the steps executable, practising step parameterisation.
Working with Cucumber.js DataTables
Introduction to Gherkin DataTables for structured data within scenarios.
Accessing DataTables in Step Definitions using the Cucumber.js DataTable object (passed as a parameter).
Processing DataTable data in JavaScript/TypeScript: Using hashes(), rows(), rowsHash(), raw() methods.
Mapping DataTable data to JavaScript objects.
Performing assertions based on DataTable data.
Hands-On Lab: Updating selected scenarios to incorporate DataTables, writing Step Definitions that access and process DataTable data from the DataTable object.
Module 6: Sharing State between Steps using the Cucumber.js World Object
The challenge of safely and cleanly sharing state between independently executed Step Definitions within a scenario.
Understanding the Cucumber.js World object: A dedicated instance for each scenario to store contextual information.
Customising the World object to include necessary properties or instances (e.g., API clients, browser instances).
Accessing the World object within Step Definitions (using this or injecting).
Using hooks (Before, After) in support files to set up and tear down state on the World object (e.g., initialising a browser instance).
Integrating with test automation frameworks (e.g., Playwright, Selenium, Cypress) by managing their instances on the World object.
Hands-On Lab: Implementing a custom World object, using hooks to manage its lifecycle per scenario, and refactoring Step Definitions to use the World object for sharing state.
Structuring Scenarios and Organising Cucumber.js Assets
Finding the right structure for Feature files within the project.
Strategies for Organising Step Definition files (.js/.ts) and functions for maintainability and discoverability in larger projects.
Using Cucumber.js Tags (@tagname) effectively for grouping, filtering, and categorising scenarios and features.
Excluding scenarios or features using tags.
Traceability: Linking scenarios to requirements, user stories, or backlog items (using conventions or integration tools - concept).
Cucumber.js Configuration (cucumber.js file or package.json): Basic configuration options.
Hands-On Lab: Restructuring feature files and step definition files, applying tags for filtering, practicing running subsets of scenarios using tags via the cucumber-js CLI.
Managing Data and Scenarios
Strategies for managing complex test data in scenarios and automation code.
Techniques for Pushing data down to the automation layer (reducing excessive data in Gherkin).
Composite steps: Calling one step definition from another (using this.Given, this.When, this.Then).
Implementing Field and workflow-level defaults for common scenario data.
Strategies for managing Baseline data and implementing test data management.
Cucumber.js Data-Driven Scenarios (Scenario Outline): Deep dive into using Scenario Outline and the Examples table for managing data variations for the same scenario structure.
Hands-On Lab: Refactoring scenarios to use composite steps, implementing data-driven scenarios using Scenario Outline and Examples in Cucumber.js, exploring strategies for test data management.
Scenarios vs. Tests & The Testing Pyramid
Clarifying the purpose: Scenarios as illustrations of behaviour vs. Tests for comprehensive coverage.
When to use Data-Driven Scenarios vs. multiple distinct scenarios.
Understanding the Automated Testing Pyramid (Unit, Integration, Acceptance/BDD, UI).
Mapping Cucumber.js scenarios to the Testing Pyramid – where automated BDD tests typically fit (Acceptance, Integration, E2E levels).
Balancing different levels of automation in a JavaScript project.
Hands-On Lab: Discussion and analysis exercise on where different types of tests fit within the testing pyramid in a JavaScript project context, evaluating existing test suites (conceptual).
Structuring the Automation Layer
Separation of automation logic and testing concerns within the Cucumber.js project structure.
Layering the automation solution (e.g., separating UI interaction, API calls, service layer logic).
Common Automation Patterns for Test Maintainability in JavaScript/TypeScript:
Page Object Model (POM) for UI automation (if applicable), using tools like Playwright or Selenium.
Patterns for API/Service automation clients (e.g., using libraries like axios or node-fetch).
Where to place Assertions in the automation layer (typically in Step Definitions).
Designing for reusability, readability, and maintainability of the JavaScript/TypeScript automation code.
Integrating automation layer objects with the Cucumber.js World object (via custom World or injection).
Hands-On Lab: Restructuring automation code using a layered approach or a pattern like POM (simplified) in JavaScript/TypeScript, demonstrating how to keep Step Definitions clean by delegating complex interactions to other classes/modules, integrating them via the World object.
Automating External Interfaces & Integration
Challenges of automating interactions with external systems (UIs, APIs).
Domain layer vs. E2E automation with Cucumber.js.
Building automation infrastructure using JavaScript/TypeScript within Cucumber.js step definitions.
Example: Web UI Automation Integration: Using Playwright or Selenium WebDriver within Cucumber.js step definitions to automate browser interactions (leveraging the World object for driver/page instances).
Example: REST API Automation Integration: Using JavaScript/TypeScript HTTP clients (e.g., axios, node-fetch) within Step Definitions.
Running Cucumber.js tests from the command line.
Understanding Cucumber.js Reports: Built-in formatters (pretty, progress) and generating reports (JSON, HTML via plugins).
Integrating Cucumber.js Tests into Continuous Integration (CI) pipelines: Configuring CI platforms (e.g., GitHub Actions, GitLab CI, Jenkins) to execute cucumber-js commands and publish reports.
Maintaining BDD Assets (Feature files and Step Definitions) in a CI/CD environment.
Hands-On Lab: Implementing Step Definitions that automate interactions with an external system (web UI or API) using a chosen automation library, running tests with reports, configuring a simple CI pipeline (simulated) to run the tests.
-
Cucumber.js Documentation: The official and comprehensive guide for installing, configuring, writing tests, and advanced features in the Cucumber.js framework. This should be your primary reference.
Gherkin Reference: Official documentation for the Gherkin language syntax used in feature files.
Playwright Documentation: A powerful Node.js library to automate Chromium, Firefox, and WebKit. Excellent for UI automation integrated with Cucumber.js.
Selenium WebDriver Documentation: A widely used framework for automating web browsers, also commonly integrated with Cucumber.js.
Node.js Documentation: Official documentation for the Node.js runtime environment.
Trusted by



