diff --git a/libs/testing/e2e/README.md b/libs/testing/e2e/README.md index 22bb04155947..40fedb39f715 100644 --- a/libs/testing/e2e/README.md +++ b/libs/testing/e2e/README.md @@ -58,12 +58,17 @@ yarn e2e yarn e2e --skip-nx-cache ``` -- **Run a Specific Project**: Run only the tests defined under a specific project in your Playwright config: +- **Run Tests with Tags**: Use tags to include or exclude specific tests. ```bash - yarn e2e -- --project=smoke - yarn e2e -- --project=acceptance - yarn e2e -- --project=everything + # Run only tests tagged with @fast + yarn e2e --grep @fast + + # Exclude tests tagged with @fast + yarn e2e --grep-invert @fast + + # Run tests tagged with either @fast or @slow + yarn e2e --grep "@fast|@slow" ``` - **View the Test Report**: After running tests, use this command to view the generated report: @@ -84,6 +89,8 @@ yarn e2e yarn e2e --debug ``` +For more details on Playwright commands and flags, refer to the [official documentation](https://playwright.dev/docs/test-cli) + ## ✍️ Writing Tests Run `yarn playwright codegen --output ` and modify the output. The selectors need special attention; they should be transformed to use roles or `data-testid` attributes for stability (see below on how to). @@ -100,14 +107,12 @@ You should therefore aim to write test for: ### πŸ—οΈ Test structure -Test cases are written in spec files. Tests that do not modify anything (e.g., _create_ an application, _change_ the user’s name, etc.) and verify basic functionality are called **smoke tests**. Tests that are more detailed and/or make any changes at all, are called **acceptance tests**. Test cases are put into folders by what app they are testing, smoke/acceptance test, and each file tests some aspect of an app. Here is an example of the folder layout for testing the search engine and front-page of the `web` project (within the system-e2e app): +Test cases are written in spec files. Tests are tagged based on their execution time or other criteria. For example, you can use tags like `@fast` for quick tests and `@slow` for longer-running tests. Here is an example of the folder layout for testing the search engine and front-page of the `web` project: ```shell web/ (app name) -β”œβ”€β”€ smoke/ (test type) -β”‚ └── home-page.spec.ts (feature name, kebab-case) -└── acceptance/ - └── search.spec.ts +β”œβ”€β”€ home-page.spec.ts (feature name, kebab-case) +└── search.spec.ts ``` ### πŸ—ƒοΈ Spec files @@ -132,7 +137,7 @@ test.describe('Overview part of banking app', () => { // Basic state reset, e.g. clear inbox }) - test('should get paid', () => { + test('should get paid', { tag: '@slow' }, () => { // Make user get money using page.selector, page.click, etc. // Verify money is present }) diff --git a/libs/testing/e2e/src/lib/config/playwright-config.ts b/libs/testing/e2e/src/lib/config/playwright-config.ts index e8f9336fc70a..d888387b0874 100644 --- a/libs/testing/e2e/src/lib/config/playwright-config.ts +++ b/libs/testing/e2e/src/lib/config/playwright-config.ts @@ -25,7 +25,7 @@ export const createPlaywrightConfig = ({ webServerUrl, port, command, - cwd = '../../../', + cwd, timeoutMs = 5 * 60 * 1000, }: PlaywrightConfigParams) => defineConfig({