Skip to content

Commit

Permalink
fix(testing): add support for playwright --last-failed (#28161)
Browse files Browse the repository at this point in the history
`--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
  • Loading branch information
agoldis authored Oct 2, 2024
1 parent 471536c commit c24292a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/generated/packages/playwright/executors/playwright.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { execSync, fork } from 'child_process';
import {
ExecutorContext,
getPackageManagerCommand,
names,
output,
workspaceRoot,
} from '@nx/devkit';
import { execSync, fork } from 'child_process';

export interface PlaywrightExecutorSchema {
/*
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions packages/playwright/src/executors/playwright/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c24292a

Please sign in to comment.