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. From VSCode remove test example folder
  7. Remove example spec file
  8. Update the playwright configuration file
    • base URL
    • project
    • headless
  9. Create a new test.spec.ts file inside the tests folder (if tests folder is selected)
  10. Start the spec file with import
    • import {test, expect} from '@playwright/test'
  11. Start test function with callback
test ( 'Test case name', async({ page }) => {

 // your test actions and assertions

})

No comments:

Post a Comment