Posts

Showing posts from November, 2025

Await and Async

Typescript and Javascript is asynchronous . This means in our test which has multiple steps there is no guarantee that they will be executed one after the other. Let us consider an example where we typically try to login to a website.  Say, I want to book the book travel tickets. Below are the steps we follow manually.  Step1: Go to the Travel website URL  Step2: Provide Username and Password  Step3: Click on Login button to get into the application If we can notice, all these steps are sequential in nature. if we try to miss step2 and with out credentials clicking on Login button would not take us to the application.  Similarly, as we are trying to do automation ( web automation ), we should ensure all these steps are followed in sequence in above scenario. And we are relying on Typescript/Javascript to enable this automation. But we should understand that these are asynhronous. Meaning the steps can be executed in any order. So t...

What is spec.ts?

The spec file is a collection of test cases. Once we have done npm init playwright, we see a function @playwright/test imported. Using this test annotation, we can define the test cases. import {test} from '@playwright/test'; Test function is what we are importing. test('Name of the test case', 'callback function' { // playwright test steps // step 1 // step 2 ........ ........ ........ }); There are some built-in test sub-functions available that we can use with the test annotation. These help in controlling which tests to run or not. Example: test.only() -- Playwright will only run this test from the specs. test.skip() -- Playwright will not run this test from the specs. test.fail() -- Playwright will validate and check if the test is failing. if not, then it will complain.