Integrating Playwright and Cucumber Tests into a CI/CD Pipeline with GitHub Actions

August 26, 2025

We’ve all been there. You’ve meticulously crafted your end-to-end tests using the power of Playwright and the clarity of Cucumber’s Gherkin syntax. Everything runs perfectly on your local machine. You push your code, confident in your work, only to hear the dreaded words later: “The latest push broke the login page.”

The classic “it works on my machine” problem highlights a critical gap in the development process: the lack of automated, consistent testing. Running tests locally is a great start, but to truly build a reliable application, you need a system that runs your entire test suite automatically on every single code change. Adopting this practice is a key step in maturing your team’s DevOps capabilities and building a culture of quality.

This is where a Playwright CI/CD with GitHub Actions pipeline comes in. It’s the ultimate safety net.

In this practical, step-by-step guide, we’ll show you exactly how to integrate your existing Playwright and Cucumber test suite into a fully automated GitHub Actions workflow. We’ll take your tests from a manual, local process to a hands-free, automated gatekeeper for your codebase.

Prerequisites Before Integrating Playwright and Cucumber Tests

Before we begin, this guide assumes you already have a few things set up:

  • A Node.js project with Playwright and Cucumber already installed and configured. If you’re starting from scratch, our detailed guide on setting up Playwright with Cucumber for BDD is the perfect place to begin.
  • A working test suite with .feature files and corresponding step definitions.
  • Your project code is hosted in a GitHub repository.

Step 1: Reviewing Your Project Structure

Project structure for Playwright and Cucumber tests in a Node.js app

A clean project structure is key. Your project should look something like this. The most important part is that your package.json file contains a test script that successfully executes your Playwright Cucumber tests.

Inside your package.json, your scripts section should have a command to run your tests. It typically looks like this:
JSON
// package.json
“scripts”: {
“test”: “cucumber-js”
},

Inside your package.json, your scripts section should have a command to run your tests.

You should be able to run npm test in your terminal and see your tests execute successfully.

Step 2: Creating the GitHub Actions Workflow File

GitHub Actions are controlled by YAML files located in a specific directory within your repository. This is where you define the triggers and steps for your automation.

  1. In the root of your project, create a new directory named .github.
  2. Inside .github, create another directory named workflows.
  3. Inside workflows, create a new file named playwright-tests.yml.

This file path (.github/workflows/playwright-tests.yml) is essential. GitHub automatically detects files in this location and treats them as workflows.

Step 3: Building and Explaining the Workflow

Now, open your new playwright-tests.yml file and paste the following code. We’ll break down exactly what each line does right after.

Building and Explaining the Workflow

Breaking Down the Workflow File:

  • name & on: These define the workflow’s name and its triggers (e.g., run on a push to the main branch).
  • jobs & runs-on: We define a single job named test that will run on a fresh virtual machine with the latest version of Ubuntu.
  • container: This is a key optimization. We’re using Microsoft’s official Docker container, which comes with all Playwright dependencies and browsers pre-installed, saving significant time.
  • steps: This is the sequence of actions our job performs. It checks out the code, sets up Node.js, installs dependencies with npm ci (which is faster and more reliable for CI), runs the tests, and finally uploads the results.
  • actions/upload-artifact: This highly recommended step takes the reports generated by Playwright and uploads them. This allows you to download and inspect detailed reports, traces, and screenshots directly from the workflow run in GitHub—incredibly useful for debugging.

Pro-Tip: Why Use a Docker Container?

The container: mcr.microsoft.com/playwright… line is a massive shortcut and a professional best practice. Without it, you would need to add several complex steps to your workflow to manually download and configure all the necessary browsers (Chromium, Firefox, WebKit) and their system dependencies on a blank Ubuntu runner. Using the official container ensures you have a perfectly consistent and pre-configured testing environment every single time, making your CI runs faster and more reliably.

Step 4: Pushing Your Code and Viewing the Results

Pushing Your Code and Viewing the Results

Commit your new .github/workflows/playwright-tests.yml file and push it to your GitHub repository.
Bash
git add .
git commit -m “ci: Add GitHub Actions workflow for Playwright tests”
git push

Navigate to the “Actions” tab in your GitHub repository. You will see your new workflow in action. GitHub will show you a live log of each step as it executes. If all tests pass, the job gets a green checkmark. If not, you can click into the failed job, view the logs, and download the playwright-report artifact to see exactly what went wrong.

Conclusion: Taking Your Pipeline to the Next Level

You have now successfully automated your BDD test suite. You’ve created a robust CI pipeline that acts as a quality gate, ensuring that no code that breaks key user flows can make it into your main branch.

This pipeline is a powerful foundation. From here, you can explore more advanced CI/CD topics to further enhance your testing strategy:

  • Implement a Matrix Strategy: For true cross-browser confidence, you can modify your workflow to run your tests in parallel across different browsers and operating systems. A matrix in your YAML file can automatically create parallel jobs for [chrome, firefox, webkit], giving you comprehensive coverage in a fraction of the time.
  • Enhance Test Reporting: Integrate tools like cucumber-html-reporter to generate more detailed, shareable reports and upload them as artifacts.
  • Build a Full CI/CD Pipeline: The “CD” in CI/CD stands for Continuous Deployment. Add a second job to your workflow that only runs after the tests pass. This new job can then automatically [deploy your Node.js application] to a staging or production environment.

Building reliable and comprehensive test automation is a core part of our expertise at Varseno. If you’re looking to implement advanced QA strategies or build out your DevOps capabilities, reach out to our expert team today.