Skip to content

Latest commit

 

History

History
98 lines (71 loc) · 3.37 KB

README.md

File metadata and controls

98 lines (71 loc) · 3.37 KB

Playwright + Cucumber + JavaScript Test Automation Framework

Overview

This framework is built using Playwright, Cucumber, and JavaScript to provide a robust and scalable solution for end-to-end test automation. It supports parallel execution, retry mechanism, logging, and multi-environment test execution.

Key Features

  • Playwright: Ensures fast and reliable browser automation.
  • Cucumber: Enables behavior-driven development (BDD) with readable test scenarios.
  • JavaScript: Provides a dynamic and widely adopted programming language for automation.
  • Reporting: Generates Cucumber reports with screenshots and videos attached for failed tests.
  • Logging: Uses Winston for structured logging.
  • Environment Management: Supports running tests in multiple environments.
  • Retry Mechanism: Retries failed tests automatically.

Tech Stack

1. Playwright

Playwright is a modern automation library that supports multiple browsers (Chromium, Firefox, WebKit) and provides robust testing capabilities.

2. Cucumber

Cucumber allows writing test scenarios in Gherkin syntax, making them easy to understand and maintain.

3. JavaScript

JavaScript is a widely used scripting language for web automation and is supported by modern test frameworks.


Dependencies

This framework utilizes the following dependencies:

"dependencies": {
  "@cucumber/cucumber": "^11.2.0",
  "@playwright/test": "^1.50.1",
  "cross-env": "^7.0.3",
  "dotenv": "^16.4.7",
  "fs-extra": "^11.3.0",
  "winston": "^3.17.0"
}
  • @cucumber/cucumber: Cucumber framework for BDD testing.
  • @playwright/test: Playwright testing library.
  • cross-env: Enables setting environment variables across platforms.
  • dotenv: Loads environment variables from .env files.
  • fs-extra: Provides additional filesystem utilities.
  • winston: A powerful logging library for better debugging.

Project Structure

  • src -> Contains all the features & Typescript code
  • test-results -> Contains all the reports related file

Running Tests

To execute the tests, use the following command:

npm test run

This command will:

  • Run Playwright tests using Cucumber.
  • Capture screenshots and videos for failures.
  • Generate reports after execution.

Running Tests in Parallel

The framework is designed to support parallel execution, improving test efficiency.

Retry Mechanism

If a test fails, it will automatically retry based on the configured retry settings.

Running Tests in Different Environments

You can configure multiple environments using .env files and switch between them using cross-env.


Reporting

This framework utilizes the default Cucumber report, which includes:

  • Detailed step execution results.
  • Screenshots and videos attached for failures.

Logging

Logging is implemented using Winston, which provides structured logs to help debug test failures effectively.


Final Thoughts

This framework provides a strong foundation for scalable and maintainable test automation using modern tools and best practices. With parallel execution, retry mechanisms, and multi-environment support, it ensures reliability and efficiency in automated testing.

Feel free to contribute, enhance, or modify this framework as needed!

Happy Testing! 🚀