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

The Core Components of Knative: Build, Serving, and Eventing

TCP Connection Analysis Why the Socket Remains in the FIN_WAIT_1 State Post Killing the Process

Using Brotli to Compress Large Files

GameDev Week 1: OOP and Delegates

How To Get Commodities Global Market Prices In 2022

Do You Want To Create A New Brand? Use A Logo API

Know Your Market With An Historical Forex Rates API

A short note on object life cycle in the .NET Framework (C#)

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

Refactoring 101: Code Smells — Bloaters

Testing Legacy Troubles

.Net Core Tee Streaming and Buffered S3 Uploads

Unable to find an OpenAPI description error in .net 6 REPL CLI tool