This project demonstrates QA automation for the Swag Labs e-commerce website. It showcases the implementation of best practices in end-to-end testing using Playwright.
- End-to-End Testing: Critical workflows such as login, sorting, and adding/removing items to/from the cart.
- Page Object Model (POM): For maintainable and scalable test design.
- CI/CD Integration: Tests are executed automatically using GitHub Actions.
- Test Reporting: JUnit format reports for detailed insights.
- Screenshots: Captured after each test for better debugging.
- Playwright: Browser automation and testing framework.
- GitHub Actions: For continuous integration and delivery.
- Node.js: JavaScript runtime.
- JUnit: Test reporting format.
-
Install Node.js.
-
Clone this repository:
git clone https://github.com/hadarlapidot/playwright_unit_testing.git
-
Navigate to the project directory:
-
Install dependencies:
npm install @playwright/test --save-dev
- Run All Tests:
npx playwright test
- Run a Specific Test Suite:
npx playwright test <test-suite-name>
- View the Playwright Report:
npx playwright show-report
This project is integrated with GitHub Actions to:
- Automatically run tests on every push or pull request.
- Generate test reports and upload them as artifacts for review.
The CI/CD pipeline is defined in the .github/workflows/test.yml
file. It:
- Installs dependencies.
- Runs Playwright tests.
- Stores the test results and reports as artifacts.
|-- .github
|-workflows
|- test.yml
|--config
|-- package-lock.json
|-- package.json
|-- playwright.config.js # Playwright configuration file
|-- data
|-- test-data.js
|-- docs
|-- Test_Plan.md # Test plan document
|-- node_modules
|-- pages
|-- inventory.page.js. # Inventory Page Object
|-- login.page.js # Login Page Object
|-- screenshots
|-- test-cases
|-- add-to-cart-tests.md
|-- login-tests.md
|-- sorting-function.md
|-- test-results
├── tests/
│ ├── login.spec.js # Login test cases
│ ├── Add-items.spec.js # Add item test cases
|-- sort-items.spec.js # sort item test cases
├── test-results/
├── playwright.config.js
└── README.md # Project documentation
- Test Plan: test-plan.md - Includes objectives, scope, and the testing strategy.
- Test Design: test-design.md - Detailed test cases for critical workflows.
- Screenshots: screenshots of test results e.g: ItemsSorted-HightoLow.png
This project demonstrates:
- Writing clean and reusable test scripts using Playwright.
- Implementing the Page Object Model for scalable test design.
- Automating test execution with CI/CD pipelines.
- Producing professional artifacts like test plans, designs, and reports.
- Debugging effectively with screenshots captured after each test.
For questions or collaboration, feel free to reach out via GitHub or email.