|
| 1 | +## Code style |
| 2 | +This project uses the recommended rules from [typescript-eslint](https://typescript-eslint.io/) and [Stylistic](https://eslint.style/) to enforce a consistent code style. |
| 3 | + |
| 4 | +Together with lint-staged and husky, the code style is enforced on every commit. |
| 5 | +To check the code style manually, you can run: |
| 6 | + |
| 7 | +```bash |
| 8 | +yarn lint # or yarn lint:fix to automatically fix some issues |
| 9 | +``` |
| 10 | + |
| 11 | +If you are using VSCode, you can install the [ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) to see the errors in the editor. Also here's a configuration for the editor to automatically fix some issues on save: |
| 12 | + |
| 13 | +<details> |
| 14 | +<summary>VSCode config</summary> |
| 15 | +You can save this configuration on `.vscode/settings.json` file |
| 16 | + |
| 17 | +```jsonc |
| 18 | +{ |
| 19 | + // Disable the default formatter, use eslint instead |
| 20 | + "prettier.enable": false, |
| 21 | + "editor.formatOnSave": false, |
| 22 | + |
| 23 | + // Auto fix |
| 24 | + "editor.codeActionsOnSave": { |
| 25 | + "source.fixAll.eslint": "explicit", |
| 26 | + "source.organizeImports": "never" |
| 27 | + }, |
| 28 | + |
| 29 | + // Silent the stylistic rules in you IDE, but still auto fix them |
| 30 | + "eslint.rules.customizations": [ |
| 31 | + { "rule": "style/*", "severity": "off", "fixable": true }, |
| 32 | + { "rule": "format/*", "severity": "off", "fixable": true }, |
| 33 | + { "rule": "*-indent", "severity": "off", "fixable": true }, |
| 34 | + { "rule": "*-spacing", "severity": "off", "fixable": true }, |
| 35 | + { "rule": "*-spaces", "severity": "off", "fixable": true }, |
| 36 | + { "rule": "*-order", "severity": "off", "fixable": true }, |
| 37 | + { "rule": "*-dangle", "severity": "off", "fixable": true }, |
| 38 | + { "rule": "*-newline", "severity": "off", "fixable": true }, |
| 39 | + { "rule": "*quotes", "severity": "off", "fixable": true }, |
| 40 | + { "rule": "*semi", "severity": "off", "fixable": true }, |
| 41 | + { "rule": "*-lines", "severity": "off", "fixable": true }, |
| 42 | + ], |
| 43 | + |
| 44 | + // Enable eslint for all supported languages |
| 45 | + "eslint.validate": [ |
| 46 | + "javascript", |
| 47 | + "javascriptreact", |
| 48 | + "typescript", |
| 49 | + "typescriptreact", |
| 50 | + "vue", |
| 51 | + "html", |
| 52 | + "markdown", |
| 53 | + "json", |
| 54 | + "jsonc", |
| 55 | + "yaml", |
| 56 | + "toml", |
| 57 | + "xml", |
| 58 | + "gql", |
| 59 | + "graphql", |
| 60 | + "astro", |
| 61 | + "css", |
| 62 | + "less", |
| 63 | + "scss", |
| 64 | + "pcss", |
| 65 | + "postcss" |
| 66 | + ], |
| 67 | + "files.exclude": { |
| 68 | + "**/.git": true, |
| 69 | + "**/.svn": true, |
| 70 | + "**/.hg": true, |
| 71 | + "**/CVS": true, |
| 72 | + "**/.DS_Store": true, |
| 73 | + "**/Thumbs.db": true, |
| 74 | + "**/node_modules": true |
| 75 | + } |
| 76 | +} |
| 77 | +``` |
| 78 | + |
| 79 | +</details> |
| 80 | + |
| 81 | +## Writing tests |
| 82 | + |
| 83 | +Follow the Playwright [best practices](https://playwright.dev/docs/best-practices) when writting tests. Use the UI mode for faster development leveraing the [locator picker](https://playwright.dev/docs/test-ui-mode#pick-locator) to easily find elements on the page. |
| 84 | + |
| 85 | + |
| 86 | +### Page Object Model |
| 87 | + |
| 88 | +To improve test readability and maintainability, we use the [Page Object Model](https://playwright.dev/docs/pom) pattern. This pattern allows us to encapsulate the logic of the pages in classes, making the tests more readable and easier to maintain. |
| 89 | + |
| 90 | +Page objects are located in the `/pages` directory. Each page object should have a class that represents the page and its methods. The page object should not contain assertions, only methods that interact with the page. |
0 commit comments