Geek Culture
Published in

Geek Culture

Grouping and Organising Test Suite in Playwright

The Playwright doesn’t have some options like a test suite, If you are familiar with Protractor we had some options like a suite in the configuration file and it allowed us to execute tests with the --suite option in the command line.

How to Create Tests Suites like Smoke or Regression in Playwright?

The playwright provides multiple options to Organize and Group your tests

  1. Organize Playwright Tests in Folder
  2. Configure Playwright Test Suites

Organize Playwright Tests in Folder

This is a very simple option, you can create multiple folders and subfolders you can put the relevant tests accordingly

For Example, if you want to group your tests that are related to home page navigation simply create multiple spec files and put them in a single folder

PlaywrightFramework
-tests
--home

---home1.spec.ts
---home2.spec.ts
---home3.spec.ts
--profile
---profile1.spec.ts
---profile2.spec.ts
---profile3.spec.ts

Once you organize your tests inside the folder structure you can simply run all the tests together with the command

npx playwright tests tests/home/

The above command will execute all the tests inside your tests/home folder

Create Test Suite in Playwright

The above option is not suitable if you want to pick a set of tests from the different folders but with tagging, you can easily execute a group of tests like smoke, regression, etc.

Let’s take an example, if you want to create test suite smoke in playwright then you can add the tag @smoke in playwright tests like below.

//test1.ts
test('Navigate to Google @smoke', async ({ page }) => {
//Some Code
});
//test2.ts
test('Some test @smoke @regression', async ({ page }) => {
//Some code
});
//test3.ts
test('Some test @smoke @regression @mysuite', async ({ page }) => {
//Some code
});

Considering the above example I have created multiple tests but I tagged the tests with different tags like smoke, regression, etc.

Now, If you want to execute only smoke tests simply use the below command

npx playright test --grep @smoke

The above command executes all the tests which you have tagged as @smoke in your playwright test script

Hope you enjoyed this article.

Reference: https://playwright.dev/

Buy me a Coffee

If you are looking for any help, support, guidance contact me on LinkedIn|https://www.linkedin.com/in/ganeshsirsi

--

--

--

A new tech publication by Start it up (https://medium.com/swlh).

Recommended from Medium

Technical Writing Using “Someone Else’s” Code

Theatre Square Coding Question

Java 8 | If statement + operator

Azure Functions

Building a CRUD RESTful API with WSO2 Micro Integrator

Master Abstraction In Java With A Real-Life Example

GemGuardian Tournament Game Testnet is now open!

The Art of Android DevOps

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ganesh Hegde

Ganesh Hegde

https://www.linkedin.com/in/ganeshsirsi/

More from Medium

Playwright Test and Browser Automation

“You are mixing async and sync code”- Fix in Cypress

Playwright test framework PageObject oriented

Wrapito: a testing philosophy as a tool