From 99ec30a9431108077f317f69668edfff13188afe Mon Sep 17 00:00:00 2001 From: Andrew Goldis Date: Wed, 2 Oct 2024 02:09:51 -0700 Subject: [PATCH] fix(testing): add support for playwright --last-failed (#28161) `--last-failed` allows running only the failed tests from the previous run. Example: `playwright test --last-failed`. [Documentation](https://playwright.dev/docs/test-cli#reference) ## Current Behavior Cannot provide `--last-failed` flag to playwright ## Expected Behavior Should be able provide `--last-failed` via configuration entry `lastFailed: boolean` ## Related Issue(s) Fixes #28096 (cherry picked from commit c24292abf489a2fc222f854aafa8b408654af55f) --- docs/generated/packages/playwright/executors/playwright.json | 4 ++++ .../playwright/src/executors/playwright/playwright.impl.ts | 3 ++- packages/playwright/src/executors/playwright/schema.json | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/generated/packages/playwright/executors/playwright.json b/docs/generated/packages/playwright/executors/playwright.json index a6d210aad88a1..cab859f13333d 100644 --- a/docs/generated/packages/playwright/executors/playwright.json +++ b/docs/generated/packages/playwright/executors/playwright.json @@ -24,6 +24,10 @@ "type": "boolean", "description": "Run tests with Playwright Inspector. Shortcut for 'PWDEBUG=1' environment variable and '--timeout=0',--max-failures=1 --headed --workers=1' options" }, + "lastFailed": { + "type": "boolean", + "description": "Run only the tests that failed in the last run" + }, "forbidOnly": { "type": "boolean", "description": "Fail if test.only is called" diff --git a/packages/playwright/src/executors/playwright/playwright.impl.ts b/packages/playwright/src/executors/playwright/playwright.impl.ts index 5ea711aba536f..93dfbb081a7db 100644 --- a/packages/playwright/src/executors/playwright/playwright.impl.ts +++ b/packages/playwright/src/executors/playwright/playwright.impl.ts @@ -1,4 +1,3 @@ -import { execSync, fork } from 'child_process'; import { ExecutorContext, getPackageManagerCommand, @@ -6,6 +5,7 @@ import { output, workspaceRoot, } from '@nx/devkit'; +import { execSync, fork } from 'child_process'; export interface PlaywrightExecutorSchema { /* @@ -15,6 +15,7 @@ export interface PlaywrightExecutorSchema { browser?: 'all' | 'chromium' | 'firefox' | 'webkit' | string; config?: string; debug?: boolean; + lastFailed?: boolean; forbidOnly?: boolean; fullyParallel?: boolean; grep?: string; diff --git a/packages/playwright/src/executors/playwright/schema.json b/packages/playwright/src/executors/playwright/schema.json index 8b2c1c39996a1..d65d7087db4de 100644 --- a/packages/playwright/src/executors/playwright/schema.json +++ b/packages/playwright/src/executors/playwright/schema.json @@ -21,6 +21,10 @@ "type": "boolean", "description": "Run tests with Playwright Inspector. Shortcut for 'PWDEBUG=1' environment variable and '--timeout=0',--max-failures=1 --headed --workers=1' options" }, + "lastFailed": { + "type": "boolean", + "description": "Run only the tests that failed in the last run" + }, "forbidOnly": { "type": "boolean", "description": "Fail if test.only is called"