Sunday, September 14, 2025

Start with Playwright with TypeScript

 Perform following steps to start,

  1. Create a new folder
  2. Open terminal in that folder
  3. Enter command "npm init playwright@latest"
  4. Go through the selection as required
  5. Remember to choose TypeScript when presented
  6. Open VScode
  7. Remove test example folder
  8. Remove example spec file
  9. Update the playwright configuration file
    • base URL
    • project
    • headless
  10. Create a new test.spec.ts file inside the tests folder (if tests folder is selected)
  11. Start the spec file with import
    • import {test, expect} from '@playwright/test'
  12. Start test function with callback
test ( 'Test case name', async({ page }) => {

 // your test actions and assertions

})