Code Conventions - IvanBezrukavyi/ts-playwright GitHub Wiki
General:
- File Name Convention: CamelCase, e.g. utils.ts, map.ts, testData.ts
- Comments: Use comments to explain complex code and document APIs
- Naming Conventions:
- Classes: PascalCase, e.g. LoginPage, User
- Functions and variables: camelCase, e.g. clickButton, loginPage, userName
- Constants: SNAKE_CASE, e.g. API_URL, TIMEOUT
Playwright Specific:
- Use Page Objects to encapsulate page elements and actions
- Use locators with descriptive names
- Use assertions to verify expected behavior
GitHub Actions Specific:
- Use workflows to automate testing and deployment
- Use environments to manage secrets and configuration
- Use artifacts to store test results
dotenv Specific:
- Use environment variables to store sensitive information
- Use .env file to define environment variables
Error Handling:
- Encapsulate error handling in global setup and teardown steps
- Use try-catch blocks to handle expected errors
- Log all errors using a centralized logging mechanism
Additional Tools:
- Use ESLint to enforce coding style guidelines
- Use Prettier to format code automatically
- Use Husky to commit with lint and formatting checks
- Use pre-commit to run checks before pushing code
Version System
- 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:
- Create a separate class for each page in the application
- Use the Page Object pattern to encapsulate page elements and actions
- Use locators with descriptive names
- Use assertions to verify expected behavior
Test Data:
- Keep test data separate from test code
- Use a dedicated class for generating test data
- Use parameterized tests to run tests with different data sets
Reporting:
- Use Allure to generate reports with screenshots and logs
- Integrate Allure reports with CI/CD pipeline
Continuous Integration & Continuous Delivery:
- Automate test execution with GitHub Actions
- Integrate test results with CI/CD pipeline
- Use code coverage tools to track progress
- Deploy code automatically based on successful tests
Code Review:
- Conduct regular code reviews to ensure quality and maintainability
- Use the provided coding conventions as a reference
- Encourage discussion and feedback on code
Additional Considerations:
- Document your code conventions in a central location
- Update your conventions as needed
- Enforce code conventions using linting tools
- Encourage team members to follow the conventions