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
This commit is contained in:
Andrew Goldis 2024-10-02 02:09:51 -07:00 committed by GitHub
parent 471536cb38
commit c24292abf4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View File

@ -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"

View File

@ -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;

View File

@ -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"