[Playwright] Conditional Tests

Usecase:

  • Run tests with a condition. In my case needed to run some of the tests on a specific environment (CI)

Solution:

  • Conditional tests with “test.only”

Techstack of my solution:

  • Playwright
  • Jest
  • Typescript

Implementation:

Add your condition before tests. As per my structure

describe()     if() --> conditional implementation

it()

it()

Tests only run if condition passed with given value.

Hope this post may save your time when needed. Happy coding :)

--

--

--

Techie | Traveler | Writer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Javascript strong-typed class without typescript

An Introduction To React’s Context API and useReducer hook

Best-Tasting Protein Bars Reviewed https://t.co/hSyKX4YBfs https://t.co/tTtydsq1nn

React v16 Technical Interview Questions

How To Develop a DApp on VeChain (I):Intro

What Exactly is React Js?

Javascript Destructuring

Best Cadence Watches Revisions Needed https://t.co/ClIgHPDWc7 https://t.co/MI2NMBOEjC

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
Dilshani Subasinghe

Dilshani Subasinghe

Techie | Traveler | Writer

More from Medium

ACID(SQL) vs BASE(No-SQL) properties

ACID vs BASE properties (SQL vs NoSQL)

How DB indexing works in a storage engine

QUEUE:

Leverage use cases to identify different types of required tests