Skip to content

Instantly share code, notes, and snippets.

@minhphong306
Created June 8, 2025 03:53
Show Gist options
  • Save minhphong306/10312a47040a7dee03a20b09355f21db to your computer and use it in GitHub Desktop.
Save minhphong306/10312a47040a7dee03a20b09355f21db to your computer and use it in GitHub Desktop.
Playwright Prompt Template

Playwright Testing Standards and Best Practices

Testing Architecture

  • Follow the Page Object Model pattern strictly
  • Separate locators and actions in page object files
  • Maintain directory structure that mirrors business logic
  • Page objects should be independent from one another when possible
  • Reuse existing page objects and utilities before creating new ones

Code Style & Patterns

  • NO conditionals in test files
  • Instead of adding comments to separate test sections, use test.step, but don't overdo it
  • Follow DRY (Don't Repeat Yourself) principle
  • Follow eslint/tslint rules
  • Do not add unnecessary comments

Development Workflow

  • Before writing new tests or page objects:
    • Analyze existing similar examples in the codebase
    • Follow established patterns and practices
    • Review the readme.md file for comprehensive best practices

File Structure

  • Page objects should follow a consistent naming convention
  • Utility functions should be centralized and well-documented (utils directory)
  • Some global variables can be found in the globalVariables directory

Error Handling

  • Implement proper timeout handling for asynchronous operations
  • Ensure tests are resilient to environmental differences
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment