Skip to content

Commit c24292a

Browse files
authored
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) <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> Cannot provide `--last-failed` flag to playwright ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> Should be able provide `--last-failed` via configuration entry `lastFailed: boolean` ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #28096
1 parent 471536c commit c24292a

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

docs/generated/packages/playwright/executors/playwright.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
"type": "boolean",
2525
"description": "Run tests with Playwright Inspector. Shortcut for 'PWDEBUG=1' environment variable and '--timeout=0',--max-failures=1 --headed --workers=1' options"
2626
},
27+
"lastFailed": {
28+
"type": "boolean",
29+
"description": "Run only the tests that failed in the last run"
30+
},
2731
"forbidOnly": {
2832
"type": "boolean",
2933
"description": "Fail if test.only is called"

packages/playwright/src/executors/playwright/playwright.impl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { execSync, fork } from 'child_process';
21
import {
32
ExecutorContext,
43
getPackageManagerCommand,
54
names,
65
output,
76
workspaceRoot,
87
} from '@nx/devkit';
8+
import { execSync, fork } from 'child_process';
99

1010
export interface PlaywrightExecutorSchema {
1111
/*
@@ -15,6 +15,7 @@ export interface PlaywrightExecutorSchema {
1515
browser?: 'all' | 'chromium' | 'firefox' | 'webkit' | string;
1616
config?: string;
1717
debug?: boolean;
18+
lastFailed?: boolean;
1819
forbidOnly?: boolean;
1920
fullyParallel?: boolean;
2021
grep?: string;

packages/playwright/src/executors/playwright/schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
"type": "boolean",
2222
"description": "Run tests with Playwright Inspector. Shortcut for 'PWDEBUG=1' environment variable and '--timeout=0',--max-failures=1 --headed --workers=1' options"
2323
},
24+
"lastFailed": {
25+
"type": "boolean",
26+
"description": "Run only the tests that failed in the last run"
27+
},
2428
"forbidOnly": {
2529
"type": "boolean",
2630
"description": "Fail if test.only is called"

0 commit comments

Comments
 (0)