This repository contains a comprehensive test suite built using Playwright, Cucumber, Typescript and Node.js for testing the functionality of the mockup Shopping Store application. The tests cover various scenarios and user interactions to ensure the reliability and accuracy of the application.
- Introduction
- Prerequisites
- Installation
- Usage
- Writing Tests
- GitHub Action
- Running Tests
- Contributing
- License
The Shopping Store Playwright Test repository is created to automate the testing process of the mockup Shopping Store application. It utilizes Playwright, a powerful Node.js library for automating browser actions, to simulate user interactions and verify the correctness of the application's features.
Before running the tests, make sure you have the following software installed on your machine:
- Node.js: Download and Install Node.js
- Git: Download and Install Git
-
Clone this repository to your local machine using the following command:
git clone https://github.com/BurakVeziran/shopping-store-playwright-test.git
-
Navigate to the cloned directory:
cd shopping-store-playwright-test
-
Install the required dependencies by running:
npm install
To run the tests, you can use the following commands:
-
Firstly run 'shopping-store-mac-arm64' or 'shopping-store-linux-amd64' files according to your operating system.
-
To run the tests in a headed mode (browser window visible), use the following command:
npm test
-
To run the tests in a headless mode (browser window not visible), use the following command:
npm run test:ci
This repository is configured to work with GitHub Actions, allowing you to automate the testing process and run tests in a CI/CD environment. The included workflow file, .github/workflows/playwright.yml, contains the necessary configuration to execute the tests whenever changes are pushed to the repository.
The workflow uses Node.js and Playwright to set up the testing environment and execute the test suite. Here's how it works:
-
When a new commit is pushed to the repository, GitHub Actions triggers the workflow defined in .github/workflows/tests.yml.
-
The workflow starts by checking out the repository code to the runner environment.
-
It installs Node.js and the required dependencies using the specified Node.js version.
-
The Playwright test script is executed using the npm test command, running the tests in a headed mode (browser window visible) by default.
The test results are displayed in the workflow log, providing information about the test execution, any failures, and the overall test status.
The test suite is organized using the folder structure under the tests
directory. Each test file represents a specific feature or functionality of the Shopping Store application. You can create new test files or modify existing ones based on your requirements.
To create a new test file, follow these steps:
- Navigate to the
tests
directory. - Create a new TypeScript file with a descriptive name that reflects the feature you want to test (e.g.,
checkout.spec.ts
). - Write your test cases using the Playwright. Refer to the Playwright documentation for detailed information on how to write tests.
When running the tests, Playwright will launch a browser instance and execute the test cases sequentially. The test results will be displayed in the console.
The tests are designed to be independent and isolated, ensuring that they can be executed individually or as a group without dependencies on previous test runs. This enables you to run specific tests or focus on specific areas of the application during development and debugging.
Contributions to this repository are welcome. If you find any issues or would like to add new features, please follow these steps:
- Fork this repository.
- Create a new branch:
git checkout -b feature/my-feature
. - Make your changes and commit them:
git commit -m 'Add some feature'
. - Push to the branch:
git push origin feature/my-feature
. - Submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.