Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: make it more clear that --only-changed is per file (#31874)
Max Schmittb214941a01d5
diff --git a/docs/src/ci-intro.md b/docs/src/ci-intro.mdindex 4e4b2bb19c..bad1e358c2 100644--- a/docs/src/ci-intro.md+++ b/docs/src/ci-intro.md@@ -386,7 +386,7 @@ jobs:### Fail-Fast* langs: js-Even with sharding enabled, large test suites can take very long to execute. Running changed tests first on PRs will give you a faster feedback loop and use less CI resources.+Even with sharding enabled, large test suites can take very long to execute. Running changed test files first on PRs will give you a faster feedback loop and use less CI resources.```yml js title=".github/workflows/playwright.yml"name: Playwright Testsdiff --git a/docs/src/test-cli-js.md b/docs/src/test-cli-js.mdindex 052c0abf1f..346d0bc8b5 100644--- a/docs/src/test-cli-js.md+++ b/docs/src/test-cli-js.md@@ -93,7 +93,7 @@ Complete set of Playwright Test options is available in the [configuration file]| `--max-failures <N>` or `-x`| Stop after the first `N` test failures. Passing `-x` stops after the first failure.|| `--no-deps` | Ignore the dependencies between projects and behave as if they were not specified. || `--output <dir>` | Directory for artifacts produced by tests, defaults to `test-results`. |-| `--only-changed [ref]` | Only run tests that have been changed between working tree and "ref". Defaults to running all uncommitted changes with ref=HEAD. Only supports Git. |+| `--only-changed [ref]` | Only run test files that have been changed between working tree and "ref". Defaults to running all uncommitted changes with ref=HEAD. Only supports Git. || `--pass-with-no-tests` | Allows the test suite to pass when no files are found. || `--project <name>` | Only run tests from the specified [projects](./test-projects.md), supports '*' wildcard. Defaults to running all projects defined in the configuration file.|| `--quiet` | Whether to suppress stdout and stderr from the tests. |diff --git a/packages/playwright/src/program.ts b/packages/playwright/src/program.tsindex 7cbe7e5461..a6c2c5fead 100644--- a/packages/playwright/src/program.ts+++ b/packages/playwright/src/program.ts@@ -355,7 +355,7 @@ const testOptions: [string, string][] = [['--max-failures <N>', `Stop after the first N failures`],['--no-deps', 'Do not run project dependencies'],['--output <dir>', `Folder for output artifacts (default: "test-results")`],- ['--only-changed [ref]', `Only run tests that have been changed between 'HEAD' and 'ref'. Defaults to running all uncommitted changes. Only supports Git.`],+ ['--only-changed [ref]', `Only run test files that have been changed between 'HEAD' and 'ref'. Defaults to running all uncommitted changes. Only supports Git.`],['--pass-with-no-tests', `Makes test run succeed even if no tests were found`],['--project <project-name...>', `Only run tests from the specified list of projects, supports '*' wildcard (default: run all projects)`],['--quiet', `Suppress stdio`],diff --git a/packages/playwright/src/runner/tasks.ts b/packages/playwright/src/runner/tasks.tsindex 7abd1f4749..4220291a08 100644--- a/packages/playwright/src/runner/tasks.ts+++ b/packages/playwright/src/runner/tasks.ts@@ -31,7 +31,7 @@ import type { Matcher } from '../util';import { Suite } from '../common/test';import { buildDependentProjects, buildTeardownToSetupsMap, filterProjects } from './projectUtils';import { FailureTracker } from './failureTracker';-import { detectChangedTests } from './vcs';+import { detectChangedTestFiles } from './vcs';const readDirAsync = promisify(fs.readdir);@@ -232,7 +232,7 @@ function createLoadTask(mode: 'out-of-process' | 'in-process', options: { filterif (testRun.config.cliOnlyChanged && options.filterOnlyChanged) {for (const plugin of testRun.config.plugins)await plugin.instance?.populateDependencies?.();- const changedFiles = await detectChangedTests(testRun.config.cliOnlyChanged, testRun.config.configDir);+ const changedFiles = await detectChangedTestFiles(testRun.config.cliOnlyChanged, testRun.config.configDir);cliOnlyChangedMatcher = file => changedFiles.has(file);}diff --git a/packages/playwright/src/runner/vcs.ts b/packages/playwright/src/runner/vcs.tsindex 160ca60840..3e5fcfc4e3 100644--- a/packages/playwright/src/runner/vcs.ts+++ b/packages/playwright/src/runner/vcs.ts@@ -18,7 +18,7 @@ import childProcess from 'child_process';import { affectedTestFiles } from '../transform/compilationCache';import path from 'path';-export async function detectChangedTests(baseCommit: string, configDir: string): Promise<Set<string>> {+export async function detectChangedTestFiles(baseCommit: string, configDir: string): Promise<Set<string>> {function gitFileList(command: string) {try {return childProcess.execSync(