Code Conventions - IvanBezrukavyi/ts-playwright GitHub Wiki

General:

  1. File Name Convention: CamelCase, e.g. utils.ts, map.ts, testData.ts
  2. Comments: Use comments to explain complex code and document APIs
  3. Naming Conventions:
  4. Classes: PascalCase, e.g. LoginPage, User
  5. Functions and variables: camelCase, e.g. clickButton, loginPage, userName
  6. Constants: SNAKE_CASE, e.g. API_URL, TIMEOUT

Playwright Specific:

  1. Use Page Objects to encapsulate page elements and actions
  2. Use locators with descriptive names
  3. Use assertions to verify expected behavior

GitHub Actions Specific:

  1. Use workflows to automate testing and deployment
  2. Use environments to manage secrets and configuration
  3. Use artifacts to store test results

dotenv Specific:

  1. Use environment variables to store sensitive information
  2. Use .env file to define environment variables

Error Handling:

  1. Encapsulate error handling in global setup and teardown steps
  2. Use try-catch blocks to handle expected errors
  3. Log all errors using a centralized logging mechanism

Additional Tools:

  1. Use ESLint to enforce coding style guidelines
  2. Use Prettier to format code automatically
  3. Use Husky to commit with lint and formatting checks
  4. Use pre-commit to run checks before pushing code

Version System

  1. Use the command line against VS Code interface. It will trigger code analysis before pushing to the branch There is a result:

Page Object Pattern:

  1. Create a separate class for each page in the application
  2. Use the Page Object pattern to encapsulate page elements and actions
  3. Use locators with descriptive names
  4. Use assertions to verify expected behavior

Test Data:

  1. Keep test data separate from test code
  2. Use a dedicated class for generating test data
  3. Use parameterized tests to run tests with different data sets

Reporting:

  1. Use Allure to generate reports with screenshots and logs
  2. Integrate Allure reports with CI/CD pipeline

Continuous Integration & Continuous Delivery:

  1. Automate test execution with GitHub Actions
  2. Integrate test results with CI/CD pipeline
  3. Use code coverage tools to track progress
  4. Deploy code automatically based on successful tests

Code Review:

  1. Conduct regular code reviews to ensure quality and maintainability
  2. Use the provided coding conventions as a reference
  3. Encourage discussion and feedback on code

Additional Considerations:

  1. Document your code conventions in a central location
  2. Update your conventions as needed
  3. Enforce code conventions using linting tools
  4. Encourage team members to follow the conventions