From e347512b7c1d8fc82fe1c759c866269f9d9722bc Mon Sep 17 00:00:00 2001 From: Andrew Goldis Date: Sat, 23 Nov 2024 01:42:50 -0800 Subject: [PATCH] .. --- README.md | 80 ++++++++++++++++++++++++++-------- apps/e2e-02/src/e2e-02.spec.ts | 12 +---- package.json | 2 +- 3 files changed, 65 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 841bd6d..dbc7fc4 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,62 @@ -## NX Currents example -This repository shows how to use NX with Currents - -## How to test it? -It is ready to use. You only need to: -- Install dependencies: `npm install` -- Execute in the root of the project: `CURRENTS_RECORD_KEY=your-key CURRENTS_PROJECT_ID=your-id CURRENTS_CI_BUILD_ID=unique-id npx nx run-many -t e2e --verbose --parallel=2` - -## Explanation -This NX workspace contains 2 projects within `apps` folder: `example-app` and `example-app-e2e`. -These two projects has as target `e2e` to that will be the target to run when using `-t e2e` in the previous command. -The `--parallel=2` will execute each project in different machines parallelizing the execution by project. - -## Considerations -- The `pwc-p` is being used as executed command in `project.json` files -- When using `CURRENTS_CI_BUILD_ID` env variable is will generate a single run for all your parallelized project -- IMPORTANT: It is not advisable to use the same Playwright project names across NX projects because it can cause a mismatch in the reported results -- [See this job](https://github.com/miguelangaranocurrents/nx-example/actions/runs/11958598465) to understand how parallelized orchestration works with NX \ No newline at end of file +# Currents Playwright NX Example + +This repository shows how to use NX + Playwright with Currents. + +## Setup + +```sh +npm i -g nx@latest +npm i +``` + +## Run + +```sh +CURRENTS_RECORD_KEY=recordkey \ +CURRENTS_PROJECT_ID=projectid \ +CURRENTS_CI_BUILD_ID=`date +%s` \ +nx run-many -t e2e --parallel=2 --verbose +``` + +### Output directory + +Playwright output directory is set in `project.json` > `targets.e2e.options.output`, for example: + +```json + "targets": { + "e2e": { + "executor": "@nx/playwright:playwright", + "options": { + "skipInstall": true, + "output": "{workspaceRoot}/playwright-report/{projectName}", + "config": "{projectRoot}/playwright.config.ts" + } + } + } +``` + +After running the tests, results will appear as: + +```plain +playwright-report/ +├── e2e-01/ +│ └── .last-run.json +└── e2e-02/ + └── .last-run.json +``` + +ℹ️ `playwright.config.ts` for each project use `nxE2EPreset` - it sets a different `output` directory, but `project.json:output` overrides it. + +## Last Failed + +nx passes down unrecognized arguments to the target command, for example + +```sh +nx run-many -t e2e --parallel=2 --verbose --last-failed +# ... + + NX Ran target e2e for 2 projects (7s) + + With additional flags: + --last-failed=true +``` diff --git a/apps/e2e-02/src/e2e-02.spec.ts b/apps/e2e-02/src/e2e-02.spec.ts index 34519e8..42bee14 100644 --- a/apps/e2e-02/src/e2e-02.spec.ts +++ b/apps/e2e-02/src/e2e-02.spec.ts @@ -1,13 +1,5 @@ import { expect, test } from '@playwright/test'; -test('e2e-02', async ({ page }) => { - await page.goto('https://todomvc.com/examples/backbone/dist/'); - - // Use locators to represent a selector and re-use them - const inputBox = page.locator('input.new-todo'); - const todoList = page.locator('.todo-list'); - - await inputBox.fill('Learn Playwright'); - await inputBox.press('Enter'); - await expect(todoList).toHaveText('Learn Playwright'); +test('e2e-02', async () => { + expect(1).toBe(1); }); diff --git a/package.json b/package.json index 7769c61..12eada4 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@nx-example/source", + "name": "currents-playwright-nx-example", "version": "0.0.0", "license": "MIT", "scripts": {},